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")

7th Jul 2020, 2:59 PM
Shivam Rawal
3 odpowiedzi
+ 3
Shivam Rawal because con already consist getElementById. You can't do getElementById (). getElementById ()
7th Jul 2020, 3:06 PM
A͢J
A͢J - avatar
+ 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.
7th Jul 2020, 3:08 PM
Ipang
+ 1
The accessing will be created with: document.getElementById("edit"); // or any other id
7th Jul 2020, 3:20 PM
JaScript
JaScript - avatar