Skip to content
Advertisement

Replace selector with array item

I would like to archive that I have an Array, with 3-4 Items and then I want to itterate throw all of them and change the selector in the function with the items of the array.

JavaScript

then my function

JavaScript

and then the foreach .btn should be like name or person, and I want maybe to add late more Items to the array. How should I do it?

for 3 functions

$('.name .btn').on("click", function()){do smth.})

$('.name .test').on("click", function()){do smth.})

$('.name .dosmth').on("click", function()){do smth.})

Name should be replaced with item of the array

I want unique function for the elements

Advertisement

Answer

Try this:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement