I have this code which allows me to swap prefixes of images which works great thanks to maniator!
$(function() {
$('img.swap').each(function(){
$(this).data('current_image', this.src);
})
$('a').click(function(){
var prefix = $(this).attr("class");
$('img.swap').each(
function() {
if($(this).data('prefix') != prefix){
this.src = $(this).data('current_image').replace('.gif', (prefix)+'.gif');
$(this).data('prefix', prefix)
}
else {
this.src = $(this).data('current_image');
$(this).data('prefix', '')
}
});
});
});
My question is am I able to add the same prefix which is being added to the image to a certain CSS file, in this instance it will be color.css so could I make it color_bw.css?
Many Thanks
yes the link tag that links the css is the same as anyother element
set the href like this
<link id="css" rel="stylesheet" href="styles/reset.css" type="text/css" />
var css = $("#css").attr("href");
var href = css.replace(".css",css+prefix);
$("#css").attr("href",href);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.