Tuesday, 15 April 2014

can we add if / else statement in Javascript's / jQuery "innerhtml" -



can we add if / else statement in Javascript's / jQuery "innerhtml" -

js :

var overlaycontainer = '<div class="customeroverlayshadow">'+ '<div class="customeroverlay">'+ '<span class="customercloseicon" title="close"></span>'+ '<div class="custwhtbg">'+ '<h2 class="customerpopheading">government business relationship validation</h2>'+ '<div class="custgreytbg clearfix">'+ // here starts if(customerinfo="changecustomer"){ '<p class="custtxtunknown">yoyo </p>'+ '<p class="custtxtprocees">would proceed using business relationship 248578</p>'+ } else{ '<p class="custtxtunknown">no no </p>'+ '<p class="custtxtprocees">would proceed using business relationship 248578</p>'+ } '</div>'+ '</div>'+ '</div>'+ '</div>'; console.log(overlaycontainer)

how about:

var overlaycontainer = '<div class="customeroverlayshadow">'+ '<div class="customeroverlay">'+ '<span class="customercloseicon" title="close"></span>'+ '<div class="custwhtbg">'+ '<h2 class="customerpopheading">government business relationship validation</h2>'+ '<div class="custgreytbg clearfix">'; // here starts if(customerinfo == "changecustomer") { overlaycontainer += '<p class="custtxtunknown">yoyo </p>'+ '<p class="custtxtprocees">would proceed using business relationship 248578</p>'; } else { overlaycontainer += '<p class="custtxtunknown">no no </p>'+ '<p class="custtxtprocees">would proceed using business relationship 248578</p>'; } overlaycontainer +='</div>'+ '</div>'+ '</div>'+ '</div>'; console.log(overlaycontainer)

javascript jquery

No comments:

Post a Comment