简体   繁体   中英

Adding TR inside td

I am trying to add tr inside td . I want to achieve like this. http://jsfiddle.net/yp4cLds9/ .

But I wanted to add tr when button is clicked.

my java script logic

$('#tbUsers2 tr').each(function (e) {
    var trow = $(this);


    if (count== 0) {
        trow.append('<td class="calculated-value"><input type="text" value="Chem Volume' + iter + '" disabled/></td>');

        count++;
    }   
    else {
        trow.append("<tr><td></td><td><input type='text' value='Chem Volume'></td></tr>");
    }
});

It is always not suggested to add 'tr' within 'td'. But still if you have to do it, then here you can do it with JavaScript:

function addTr(){
    var tr = document.createElement('tr');
    tr.innerHTML = '<td>Hello</td>';

    document.getElementById("anyTDid").append(tr);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM