Reputation: 8463
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...
Upvotes: 0
Views: 165
Reputation: 8463
My Final Solution...
$("#textbox_id").html('html content given here'); $("#textbox_id").find('img').each(function() { alert($(this).attr("id")); });
Upvotes: 0
Reputation: 93694
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"));
});
Upvotes: 1