3 replies [Last post]
sus4th
Offline
newbie
www.readitsideways.com/cv
Last seen: 11 years 5 weeks ago
www.readitsideways.com/cv
Timezone: GMT+2
Joined: 2010-05-12
Posts: 2
Points: 3

Hi

I have a rule for a breadcrumb trail that uses :last-child to style the last item differently. The issue is that the trail gets updated with javascript to add new items to the end of the trail, so that what was the last item when the page loaded becomes the second last etc...

In Firefox :last-child works fine and FF updates so that only the new element has the :last-child styling, but in chrome both the original last child and the new last child are styled (ie the original keeps the :last-child styles).

There is a :hover style as well and after the mouse has rolled over the elements it is corrected in Chrome.

Is there a was to get Chrome to update the :last-child styles when the new element is added to the list?

Thanks

Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 2 days 16 hours ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5343
Points: 2964

You could try doing something

You could try doing something with JavaScript to trigger the change.
It might be as easy as changing the focus to the new item after it is added.

sus4th
Offline
newbie
www.readitsideways.com/cv
Last seen: 11 years 5 weeks ago
www.readitsideways.com/cv
Timezone: GMT+2
Joined: 2010-05-12
Posts: 2
Points: 3

Thanks, I eventually assigned

Thanks, I eventually assigned classes with javascript. It would have been nice a clean if :last-child updated in Chrome Sad

Stomme poes
Stomme poes's picture
Offline
Elder
Netherlands
Last seen: 9 years 33 weeks ago
Netherlands
Timezone: GMT+2
Joined: 2008-02-04
Posts: 1854
Points: 378

I thought I heard IE also

I thought I heard IE also doesnt update styles when teh Dom is changed. This :last-child is working in IE??

It makes more sense to use JS for this, because only those with JS will get the updated DOM anyway. Kinda like making a js-only button appear with JS, so those without JS don't even see a useless button in the first place.

I'm no expert, but I fake one on teh Internets