Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

create multiple buttons in javascript

let i = 1;
let body = document.getElementsByTagName("body")[0];

for (i; i <= 20; i++) {
  let button = document.createElement("button");
  button.innerHTML = 'Button '+i;
  body.appendChild(button);
  button.addEventListener ("click", function() {
    alert(this.innerHTML);
  });
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: where to initialize state in react 
Javascript :: bubbling and capturing in javascript 
Javascript :: check cookies client side 
Javascript :: smtp testing 
Javascript :: bootstrap and masonry 
Javascript :: start button js 
Javascript :: javascript problem solving interview questions 
Javascript :: create http request 
Javascript :: Each then() should return a value or throw 
Javascript :: web scrape example js 
Javascript :: js ?. 
Javascript :: javascript xpath 
Javascript :: javascript find missing number 
Javascript :: crypto js 
Javascript :: how to check request type in js 
Javascript :: update state in useState hook 
Javascript :: react clone element 
Javascript :: Discord.client on 
Javascript :: flightphp 
Javascript :: message.channel.name.includes 
Javascript :: convert text to qr code in angular 
Javascript :: Send Data Using Express With Post 
Javascript :: jsx react 
Javascript :: hot to start cypress 
Javascript :: elastic search host using docker 
Javascript :: react link vs navlink 
Javascript :: js push 
Javascript :: react table with styles 
Javascript :: how to add attribute in a element 
Javascript :: mongoose max record 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =