i have html template consists of table , add button. when add button clicked, selections added table. want add condition if 1 of selections contains "map" should add modal particular column. example:
<div class="reports"> <div class="panel"> <table class="a"> <thead> <td>a</td> <td>b</td> <td>c</td> </thead> <tbody> </tbody> </table> </div> <button class="add" type="button">add</button> </div> jquery script is:
$('.reports').on('click','.add',function(){ $(this).find('table').append(table rows);// how add condition inside append }); there 3 values 3 columns: value1, value2, value3:
if text2=="map"{ value2 = "modal-dialog"; } else { value2 = text2; } how add if condition inside append()?
instead of adding condition inside append(). try outside , call element in append(). example:
$('.reports').on('click','.add',function(){ if (text2 == map_text) { var map_elements += '<button role="button" data-target="#map-id" class="map-btn btn btn-primary" data-toggle="modal">map</button></span>'; } else { var map_elements += text2; } $(this) .find('table') .append('<tr><td>'+map_elements+'</td></tr>'); //this should work });
Comments
Post a Comment