New course! Every coder should learn Generative AI!
Try a free lesson- 1
I want to change width of hr tag by using getElementbyId
In this code I want to change the value of hr width as the number entered by viewer in input box. Can I do ? How ? https://code.sololearn.com/WJb9zVou7XCG/?ref=app
2 Answers
+ 5
+ 2
Captain HRK
function main(){
var x = document.getElementById("a");
var y=document.getElementsByTagName("hr");
y[0].style.width=x.value+"px";
}
OR
function main(){
var y=document.getElementsByTagName("hr");
y[0].width=document.getElementById("a").value;
}