Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how can we give the index of an array as an ID to an element

//Here the delete button gets a unique ID everytime, the ID is the array index of the element. 
array.forEach(function (element, index) {
      display =
        display +
        `<tr>
            <th scope="row">${index + 1}</th>
            <td>${element.first}</td>
            <td>${element.second}</td>
            <td>${element.third}</td>
            <td><button type="button" id="${index}" onclick="deleteNode(this.id)" class="btn btn-danger">Delete</button></td>
        </tr>`;
    });
Comment

PREVIOUS NEXT
Code Example
Javascript :: convert an iterable object to an array 
Javascript :: MIME type Error CSS in nodejs Express 
Javascript :: why I can not insert image with ajax request 
Javascript :: operator precedence javascript 
Javascript :: teste google script 
Javascript :: wait in js 
Javascript :: angular cli generate component no tests 
Javascript :: js event problem solving 
Javascript :: javascript loop area 
Javascript :: javascript plugin bootstrap 
Javascript :: Create Dynamic Screenshot of any element on a web page - JavaScript 
Javascript :: replace with regex capture group 
Javascript :: 1541847516 
Javascript :: node code to read json file 
Javascript :: is the g required at the end of a regex expression 
Javascript :: spherical.computeheading javascript 
Javascript :: oracle apex interactive grid set record field readonly 
Javascript :: 4.8. Input with readline-sync¶ 
Javascript :: composite key knex 
Javascript :: get nested value on object react using dot 
Javascript :: node js passport local for sqlite 
Javascript :: exit forEach when null javascript 
Javascript :: (Math.floor(Math.random() * 90000) + 10000).toString(); 
Javascript :: react default value for props not showing up 
Javascript :: react native getting older version assets 
Javascript :: javascript array group duplicates 
Javascript :: create component with COUNT 
Javascript :: angular dynamic script loading 
Javascript :: javascript call url without going to it 
Javascript :: convert space to dash/hyphen javascript regex 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =