Extract href from html with jQuery -


I'm trying to get the value of the href from an anch I code looks like

var html = "& lt; a href = ';";
Warning (jQuery ("a", html) .attr ("href"));

The only output I'm getting is 'undefined' I want to get "".

Any help is greatly appreciated.

Try:

  jQuery (html) .attr (' Href ');  

Or if and tag is more deep in HTML than your example:

  jQuery. It seems ('one') attr ('href'). The jQuery ()  function will convert HTML strings into DOM objects, and will return a jQuery object to them. 


Comments