I have some images with class name \".mute_btn\" and when i click on them, my images source is changing :
$(\'.mute_btn\').toggle(function () {
var c
LIVE DEMO
$('.mute_btn').click(function () {
var src = this.src;
var isClicked = src.indexOf('-over') > -1 ; // true if '-over' is found
if( isClicked ){
this.src = src.replace(/(.*)-over\.(png|gif|jpg|jpeg)$/, "$1.$2");
}else{
this.src = src.replace(/(.*)\.(png|gif|jpg|jpeg)$/, "$1-over.$2");
}
});
LIVE DEMO using ternary operator
$('.mute_btn').click(function () {
var src = this.src;
var isClicked = src.indexOf('-over') > -1 ;
this.src = isClicked ?
src.replace(/(.*)-over\.(png|gif|jpg|jpeg)$/, "$1.$2") :
src.replace(/(.*)\.(png|gif|jpg|jpeg)$/, "$1-over.$2") ;
});