Issue
I want to write something like this in javascript:
var all_headings = document.getElementsByTagName("h1,h2,h3,h4,h5,h6");
all_headings would then be a list of all elements that are h1 or h2 or h3... And in the order that they appear in the document, of course.
How do I do it?
Solution
With modern browsers you can do
document.querySelectorAll("h1, h2, h3, h4, h5, h6")
Or you could get cross-browser compatibility by using jQuery:
$("h1, h2, h3, h4, h5, h6")
Answered By - Alex Turpin
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.