+ 31
How can receive a number from user and use it in html tag ?
for example for this html code input x(number) from user and use that in <marquee scrollamount="x"> <marquee> https://code.sololearn.com/WTDuxdOWF90F/?ref=app
9 odpowiedzi
+ 5
<head>
<script>
function ScrollAmount () {
var marquee = document.getElementById ("myMarquee");
var input = document.getElementById ("amount");
marquee.scrollAmount = input.value;
}
</script>
</head>
<body>
<marquee id="myMarquee" style="width:150px;" scrollamount="10">Hi There!</marquee>
<br />
<input id="amount" type="text" value="20" />
<button onclick="ScrollAmount ();">Change scrollAmount!</button>
</body>
+ 30
Lord Krishna
Thank you , it works👍
https://code.sololearn.com/W68C4rMyeW9j/?ref=app
+ 27
Shudarshan Rai
Yes 😁
but why it just change first marquee tag ?
is it possible to change all of scrollamount with using one input?
+ 25
Shudarshan Rai
Thanks alot
+ 12
Updated: applies to all elements AliR૯za
1st Prompt for a user input
2nd select all elements with querySelectorAll
3rd loop through the nodelist with foreach then apply setAttribute to all elements
//Javascript code
this.addEventListener("DOMContentLoaded", boot)
function boot(){
var inpt = prompt("enter a no"),
mar = document.querySelectorAll("marquee")
mar.forEach(function(node){
node.setAttribute("scrollamount", inpt)
});
}
+ 3
here is in your code
https://code.sololearn.com/WTubKb2MezAH/?ref=app
+ 3
AliR૯za 👍👍
Is this helped you 😁
+ 2
AliR૯za you can by giving them different id
+ 1
wow that's awesome 😍