Location: Given the url, I would need all the classes used within the page.
There is a method of class DomDocument
that I would need to use ( ->loadHTMLFile($url)
).
Is there anything equivalent to this class for javascript
or angularjs
?
-
I needed to load a
url
and then search the tags (I would just like to get classes)$dom = new DOMDocument; $dom->loadHTMLFile('https://www.youtube.com/'); // a url vai aqui $elements = $doc->getElementsByTagName('input'); foreach($elements as $el){ //retorna todas as classes referente aos inputs echo $el->getAttribute('class')."\n"; }
In javascript you can only search the current page (where the script is inserted), for example:
-
I wanted to make given a
url
and hence the search forclasses
var $elements = document.getElementsByTagName('input'); var show = ""; for(var i = 0; i < $elements.length; i++){ var tagClass = $elements[i].getAttribute('class'); if( tagClass !== null){ show += tagClass ; } } alert(show);