Reputation: 26392
I use CTRL+SHIFT+I to open the JS Console on a page I am working on (not one I am actively developing) in Chrome Version 86.0.4240.111, I immediately start to type document.getElementById('Clear All')
and I get back null
But after I click the Elements
tab, and inspect the element with the id="Clear All"
attribute, running the same function (document.getElementById('Clear All')
) returns the element.
Does this have something to do with there being a space in the id
attribute? Is there a way to preload the DOM so that I can pull the Clear All
element without inspecting the page first?
Additionally of note, this page has <frameset>
s and the element I want to access is inside one.
Considering this is a newer product, I really can't believe they use <frameset>
s.
Upvotes: 2
Views: 517
Reputation: 89
Don't use space on ID ... try id="clear-all" on element and on javascript-> document.getElementById("clear-all")
Upvotes: 1