I have a div that contains HTML data (this changes and is user generated).
Included in this data are various anchor tags. I need to find all the tags, and remove the href attribute.
However, I don’t seem to be able to get my selectors just right.
Here is the the jQuery:
var divForHtml = $('#Content');
divForHtml = $(divForHtml +'a').attr('href', '');
Once that has been done, I need to send this variable to a function that will then continue processing the HTML.
In this situation
divForHtmlis a jQuery object; so you can’t simply append the string' a'to it to build a new selector.Instead, try using the
find()method, to search the descendants of the matched element;Although you might like the
removeAttr()method more;