Get html tags from string javascript
Using Alternatively, is it possible to get the entire HTML of the page (including doctype,
Chris Martin 29.7k8 gold badges74 silver badges131 bronze badges asked Nov 16, 2010 at 17:20
Justin StaytonJustin Stayton 5,7218 gold badges35 silver badges43 bronze badges This is how to get the html DOM element purely with JS:
or
And if you want to use jQuery to get attributes from it...
answered Jan 29, 2013 at 22:12
posit labsposit labs 8,6004 gold badges36 silver badges59 bronze badges 1 In addition to some of the other answers, you could also access the HTML element via:
Then you could get the inner HTML content:
Doing so this way seems to be marginally faster. If you are just obtaining the HTML element, however, After you have the HTML element, you can mess with the attributes with the
For the DOCTYPE, you could use
answered Sep 8, 2013 at 1:59
doubleswirvedoubleswirve 1,3283 gold badges16 silver badges22 bronze badges 2 In jQuery:
In plain Javascript:
answered Nov 16, 2010 at 17:22 0 if you want to get an attribute of an HTML element with jQuery you can use so http://api.jquery.com/attr/ Additionally:there is a jQuery plugin here: http://plugins.jquery.com/project/getAttributes that allows you to get all attributes from an HTML element
answered Nov 16, 2010 at 17:22
bimbom22bimbom22 4,4622 gold badges30 silver badges46 bronze badges 1 I found other alternative simple way using plain javascript:
answered Jan 23 at 12:55
|