javascript - Hide a row if value returned is empty -


i feel little stupid asking question reason cant life of me think on how want.

i have <div class="row"> has field label , field in it.

i want hide row if value of field returned empty.

html (held in cms system):

<div id="rollnumber" class="row">      <label class="col-sm-offset-2 col-sm-3 control-label">[!rollnumberlabel]</label>      <div class="col-sm-2 form-control-static">[!rollnumber]</div> </div> 

view code:

if (newbankdetails.rollnumber != null && newbankdetails.rollnumber != "") {      template.nvc.add("[!rollnumberlabel]", "roll number");      template.nvc.add("[!rollnumber]", newbankdetails.rollnumber); } 

i tried doing:

template.nvc.add("[!rollnumberlabel]", ""); template.nvc.add("[!rollnumber]", ""); 

but adds white space between row above , below row.

i'm suggestions whether javascript, jquery, css or if can done, using html (although don't think can done way).

i can't add code cms needs done in code.

my site using twitter bootstrap

you can test if label text empty or not.

$(function() {     $(".row").each(function() {         if ($("label", this).text() == "" ) {             $(this).hide();         }     }); }); 

working demo: http://jsfiddle.net/m7nytbw4/


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -