JavaScript erhalten Element durch ID
var element = document.getElementById("YourElementId");
Batman
var element = document.getElementById("YourElementId");
var element = document.getElementById("YourElementId");
var value_element = document.getElementById("YourElementId").value;
var myElement=document.getElementById("someElementID");
// Get the ID from Element
let element = document.getElementById('elementId')
console.log(element.id) // Get the ID
// Get value from input Element
let element = document.getElementById('elementId')
console.log(element.value) // Get the value
All currently used browsers:
element.id=id;
myElement.id=newId;
element.className=class;
myElement.className=newClassName;
async function test (){
document.body.innerHTML = await "<foo id='successGetID'>Hello Wolrd</foo>";
var init = await document.getElementsByTagName("foo")[0].id;
alert( init );
}
test();