Hello!

I have some i like this:
<i class="pcon" style="background-image: url(./styles/SkyBoot/imageset/topic_unread.gif); background-repeat: no-repeat;">

I want to change only this:
styles/SkyBoot/imageset
to this:
styles/SkyBoot/imageset/black

Because i have cookies and i want to create second template. I want this to change images for my black template (second theme)

I try with:
jQuery('.pcon').each(function(e) {return e.css.replace('styles/SkyBoot/imageset/', 'styles/SkyBoot/imageset/black');});

but without success.
I need for each element, because i have more than one. Thanks for any help!

// short version
$('.pcon').each(function(){
         $(this).css('background-image',$(this).css('background-image').replace('/styles/SkyBoot/imageset/','/styles/SkyBoot/imageset/black/'));
    }
);

// long version for clarity
$('.pcon').each(function(){
        var el = $(this);
        var oldBackground = el.css('background-image');
        var newBackground = oldBackground.replace('/styles/SkyBoot/imageset/','/styles/SkyBoot/imageset/black/');
        el.css('background-image',newBackground);
    }
);

However, find/replace is not the best way to deal with alternating themes. You could save a lot of hassle like this even by using a different stylesheet for each theme.

Thanks and I know but its phpbb theme and its hard to work with 2 stylesheets.

However, your two versions not working for me.

Are you running them after the elements have been loaded?

No i running it before :)
I added ( document ).ready(function() { and it works! Thank you!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.