Pa zar se to ne dešava, u kom browser-u testiraš kod. Ili ja nisam dobro razumeo problem.
HTML kôd:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
#kat1 {
background-image:url(ikoniceKategorije/07.jpg);
width:30px;
height:30px;
float:left;
}
#kat2 {
background-image:url(ikoniceKategorije/06.jpg);
width:30px;
height:30px;
float:left;
}
#kat3 {
background-image:url(ikoniceKategorije/05.jpg);
width:30px;
height:30px;
float:left;
}
#kat4 {
background-image:url(ikoniceKategorije/04.jpg);
width:30px;
height:30px;
float:left;
}
#kat5 {
background-image:url(ikoniceKategorije/03.jpg);
width:30px;
height:30px;
float:left;
}
#kat6 {
background-image:url(ikoniceKategorije/02.jpg);
width:30px;
height:30px;
float:left;
}
#kat7 {
background-image:url(ikoniceKategorije/01.jpg);
width:30px;
height:30px;
float:left;
}
#div {
width:220px;
height:30px;
overflow:hidden;
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
$(function() {
$('#div div').click(function() {
var elem = $(this);
var style = elem.css('background-image');
if(/h\.jpg/.test(style)) {
elem.css('background-image', style.replace(/h\.jpg/, '.jpg'));
} else {
elem.css('background-image', style.replace(/\.jpg/, 'h.jpg'));
}
});
});
</script>
</head>
<body>
<div id="div">
<div id="kat1"></div>
<div id="kat2"></div>
<div id="kat3"></div>
<div id="kat4"></div>
<div id="kat5"></div>
<div id="kat6"></div>
<div id="kat7"></div>
</div>
</body>
</html>