How to collect ElementById starting with a specific word?

Using Prototype and Script.aculo.us, I try to make all tags with an identifier starting with the “idea” of Droppable , but I can’t remember how to get all the tags starting from a specific line. Thank you in advance.

+3
source share
3 answers

Give them a class and do $$ ('div.idea');

+3
source

The previous answers are correct, use the class name instead.

However, if you are forced to use identifiers, there is a CSS selector method now supported by most JS frameworks:

$$('*[id^=idea]')
+4
source

. .

, , - , . ( jQuery $('.class')). , JS- ( getElementsByClassName) , .

: $$('.class') .

+1

Source: https://habr.com/ru/post/1787254/


All Articles