Mayukh Raaj Mayukh Raaj - 9 days ago 9
Javascript Question

How to include rowspan and colspan dynamically inside <td> tag based on some conditions

I know i can include statically when i want to merge the columns but if i need to check some conditions and based on that only i need to merge then how this could be done?

my idea was like this:

var span="";
if(some condition)
span="colspan=10";


and then setting this variable inside as:

<td +span+>


but it doesn't work like that…Any suggestion how to do this?

Answer
var span='';
var table='';

if(some condition)
  span="colspan=10";


var table="<tr><td"+span+"></td></tr>":
Comments