I just created a star rating system that change image on mouse over., but i cant seem to display the stars inline. they get under each other. It dosent work with style sheet so I suppose it should be re written in the javascript. !?
这是我的 Java本功能。
html Code :
<div id="star">
<div id="star_1" onclick="SendRating(1);" onmouseover="rateStar(1)" >
<img src="star2.png" id="rating_1" onclick="SendRating(this.getAttribute( score ));" alt="star_1" /></div>
<div id="star_2" onclick="SendRating(2);" onmouseover="rateStar(2)" >
<img src="star2.png" id="rating_2" onclick="SendRating(this.getAttribute( score ));" alt="star_2" /></div>
<div id="star_3" onclick="SendRating(3);" onmouseover="rateStar(3)" >
<img src="star2.png" id="rating_3" onclick="SendRating(this.getAttribute( score ));" alt="star_3" /></div>
<div id="star_4" onclick="SendRating(4);" onmouseover="rateStar(4)" >
<img src="star2.png" id="rating_4" onclick="SendRating(this.getAttribute( score ));" alt="star_4" /></div>
<div id="star_5" onclick="SendRating(5);" onmouseover="rateStar(5)" >
<img src="star2.png" id="rating_5" onclick="SendRating(this.getAttribute( score ));" alt="star_5" /></div>
<p id="ContentHolder">
</p>
</div>
Java:
function rateStar(rating){
var i = 1;
var ratings = ;
for (i==1; i<=5; i++){
if (i<=rating){
document.getElementById( rating_ +i).src= star1.png ;
}
else{
document.getElementById( rating_ +i).src= star.jpg ;
}
}
}
页: 1
<div id="star_1" onclick="SendRating(1);" onmouseover="rateStar(1)" >
<img src="star.jpg" id="rating_1" onclick="SendRating(this.getAttribute( score ));" alt="star_1" /></div>
CSS
#star{
position:absolute;
color:#fff;
margin-top:100px;
margin-left:1000px;
display:inline block;
}
the mouse over function is working great except that it wont display inline =/ Thanks