0
I'm facing some. Problem suppose I have element with id="Container" in html and I access it using js
var con = document.getElementById("Container") And inside container I have 2 buttons one with id="edit" and one with "delete" When I use this query to access buttons there is no problem con.getElementsByTagName("button")[0] con.getElementsByTagName("button")[1] But when I try this I get error con.getElementById("edit") con. getElementById("delete")
3 odpowiedzi
+ 3
Shivam Rawal because con already consist getElementById.
You can't do
getElementById (). getElementById ()
+ 2
What value is set for ID attribute of the buttons? did they match the argument you pass to getElementById?
(Edit)
You can use `con.querySelector("#edit")` instead. `getElementById` was not bound to <con> apparently.
+ 1
The accessing will be created with:
document.getElementById("edit"); // or any other id