开发者

I need to fetch html tags given inside textbox using jquery

I had to fetch html elements and its attributes that is given inside textbox. How can i fetch it using jquery.My code is...

    $("#textbox_id").html().filter('img').each(function() {
  开发者_运维技巧      alert($(this).attr("id"));
    });

In my above code i like to get id of all img tags inside textbox...


Textboxes don't have html inside them, they only have a value, which you can access via .val(). Then you pass that string to jQuery:

var textboxHTML = $("#textbox_id").val();
$(textboxHTML).filter("img").each(function () {
   alert($(this).attr("id"));
});


My Final Solution...

$("#textbox_id").html('html content given here');   

$("#textbox_id").find('img').each(function() {
        alert($(this).attr("id"));
    });
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜