我的html代码是
<div id="starimg">
<a href="#" class="imgstar" onclick="ratingFunc()"><img src="images/star1.png" class="star" /></a>
<a href="#" class="imgstar" onclick="ratingFunc()"><img src="images/star1.png" class="star" /></a>
<a href="#" class="imgstar" onclick="ratingFunc()"><img src="images/star1.png" class="star"/></a>
<a href="#" class="imgdarkstar" onclick="ratingApp()"><img src="images/star2.png" class="star1"/></a>
<a href="#" class="imgdarkstar" onclick="ratingApp()"><img src="images/star2.png" class="star1" /</a>
</div>
我的java脚本代码是
function ratingFunc(){
if( $('.star').attr("src")=='images/star1.png'){
$(this).replaceWith("<img src='images/star2.png' class="star1"/>");
starcheck=true;
}
else{
$(this).replaceWith("<img src='images/star1.png' class="star"/>");
starcheck=false;
}
}
function ratingApp(){
if($('.star1').attr("src")=='images/star2.png'){
$(this).replaceWith("<img src='images/star1.png' class="star"/>");
starcheck=true;
}
else{
$(this).replaceWith("<img src='images/star2.png' class"star1"/>");
starcheck=false;
}
}
当我单击图像时,这些功能不起作用..请帮助我。提前致谢。