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")); });
精彩评论