Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript get multiple elements by id

<!-- html -->
<a class="test" name="Name 1"></a>
<a class="test" name="Name 2"></a>
<a class="test" name="Name 3"></a>

// javascript
var elements = document.getElementsByClassName("test");
var names = '';
for(var i=0; i<elements.length; i++) {
    names += elements[i].name;
}
document.write(names);
Comment

PREVIOUS NEXT
Code Example
Javascript :: jest mock createobjecturl 
Javascript :: how to get checked value of checkbox in jquery 
Javascript :: is javascript good 
Javascript :: how to copy value instead of reference js 
Javascript :: scroll to top js 
Javascript :: if else dart 
Javascript :: add li to ul javascript 
Javascript :: timestamp convert moment vue 
Javascript :: get external api node js 
Javascript :: forin js 
Javascript :: how to find hcf of 2 numbers in javascript 
Javascript :: hmac_sha256 node 
Javascript :: how to add property to object in javascript 
Javascript :: create angular project 
Javascript :: simple javascript function 
Javascript :: Delete Properties from a JavaScript Object 
Javascript :: javascript and operator 
Javascript :: nodejs dotenv path how to set 
Javascript :: vue js default props 
Javascript :: angularjs datetime 
Javascript :: capitalize a string javascript 
Javascript :: javascript calculator 
Javascript :: how to import js via script in react 
Javascript :: Easy REACT download image 
Javascript :: javascript insert element after 
Javascript :: async import javascript 
Javascript :: require a json as a string 
Javascript :: Array sum by function in javascript 
Javascript :: how to download file from link in react 
Javascript :: bootstap jquery 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =