Skip to content
Advertisement

execution script for several ID – loop?

I’m downloading ID from localStorage.getItem(1,22,3,14….). I want every single ID to be executed in jQuery (if it exists on the website). I can execute the code for one ID, but I don’t know what to do to make each ID after the decimal point executed. I try so but it doesn’t pass. I have to loop it, right? can anyone help?

JavaScript
JavaScript

Advertisement

Answer

  1. Split your string into an array using the split function.
  2. Loop through your ids and process each id in turn.

JavaScript
JavaScript

Alternative version using a css class

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