jochen6677
jochen6677

Reputation: 119

Is it possible to identify a DOM element as unique?

Is it possible to identify a DOM element as unique via clicking on it and change it later via jquery replaceWith method?

Upvotes: 0

Views: 68

Answers (1)

Quentin
Quentin

Reputation: 943510

You can identify the clicked element with the target property of an event object.

addEventListener("click", event => {
    const element = event.target;
    console.log(element);
    // Now do whatever you like with the element 
});
<button>a</button>
<button>b</button>
<button>c</button>
<button>d</button>
<button>e</button>

Upvotes: 1

Related Questions