开发者

jQuery .html not working on td

I have a table cell with a text box in it, and I'm trying to take the value of the text box and put it back into the table cell while removing the text box. I'm doing this for a while row. So I have this:

        tds.each(function(i) {
            var val = $(this).children('input').eq(0).val();
  开发者_Go百科          document.getElementById($(this).attr('id')).innerHTML = val;
            //$(this).html(val);
            //$(this).text(val);
        });

As you can see, I tried a few different ways, and with all of them, nothing happens. I don't get any errors either. Not sure whats going on.


Have you verified that the collection tds has any items in it? Whenever nothing happens and an error is not thrown, I look at the jQuery selector first.


Try:

var tds = $('#table_id td');

tds.each(function(i) {
   var val = $(this).children(':input:eq(0)').val();
   $(this).html(val);
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜