AdiCrainic
AdiCrainic

Reputation: 276

Change CSS for <li> items with different ID in Javascript or CSS

Hy, I want to apply a css style for all my < li > tags after their id...the problem is that these tags have different id(autoincremental)...I made a screenshot in my firebug:

enter image description here

For all < li > items, ID is "abc_dev_view_menu_i*",where * is a number wich increments for each new item I add.

So how to manage this,how to apply the same style for all < li > in this case where the number from ID increments each time I add one item?I tried with javascript,using getElementById but nothing worked until now

Upvotes: 0

Views: 326

Answers (3)

Fabrizio Calderan
Fabrizio Calderan

Reputation: 123377

Use this attribute selector:

li[id^="abc_dev_view_menu_i"] {
   /* common style */
}

this CSS rule will apply a style to each li whose idattribute starts with abc_dev_view_menu_i (regardless of the incremental counter)

Upvotes: 4

dennitorf
dennitorf

Reputation: 319

build the id with a loop instruction,

for (i .....) id="abc_dev_view_menu_i"+i;

Upvotes: 0

user2672373
user2672373

Reputation:

Or you can use a single class for all li to which style is to be applied

Upvotes: 0

Related Questions