![]() ![]() Libraries such as jQuery handle this for you it's probably a good idea to let them do the heavy lifting.įor anyone dealing with ancient browsers, note that querySelectorAll was introduced to Internet Explorer in v8 (2009) and fully supported in IE9. You can work around this if necessary by looping through all the elements on the page to see whether they have the attribute set: var withProperty = ,Įls = document.getElementsByTagName('span'), // or '*' for all types of element It would be better to specify a tag name if possible: document.querySelectorAll('span') This finds all elements with the attribute property. (Complete list of attribute selectors on MDN.) const boxes document.querySelectorAll('div, span') console.log( boxes) // NodeList 5 Invoke the querySelectorAll () method on the document object. document.querySelectorAll('') // All with attribute named "property"ĭocument.querySelectorAll('') // All with "property" set to "value" exactly. Get Element (s) By Multiple Tag Names Using the querySelectorAll () method, get one or more elements by multiple tag names in a single query. the
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |