| Цитата(Aliance @ 13.11.2012, 15:01) | | Такого события нет. Есть события mouseover/mouseout, а есть jQuery метод hover, который биндит из оба. Уточни что тебе нужно получить. |
После загрузки в див формы, хочу сделать оценку товара. рисую 5 звез, хочу что бы по ним двигали и они красились. Нажал и остановились. Но что то мерчает сильно курсор
| Код | #productRate {background:url(../images/stars.png);width:150px;height:30px;position:relative;} #productRate div {background:url(../images/stars.png) left bottom;width:0; height: 100%; position: absolute; top: 0; left: 0; z-index: 1;cursor: pointer;} #productRate span {display:block; height: 100%;position:absolute;top:0;left: 0;z-index: 2;background: url(../images/stars.png)left center;width:0;cursor:pointer;} .objRate_black{background:url(../images/stars.png);width:150px;height:30px;position: relative;} .objRate{background:url(../images/stars.png) left bottom;width:0;height:100%;position: absolute;top:0;left:0;z-index:1;}
$(document).on('submit', "#form_resp_ajax", function(ev){ var old_text = $("#form_resp_ajax .btn").html(); $("#form_resp_ajax .btn").html(img1_loading); $("#form_resp_ajax .btn").addClass("disabled").attr("disabled",true);
$.ajax({ type: "post", url: "/java/ajax/add_response.html", data:$("#form_resp_ajax").serialize(), success:function(html){ $("#facebox_content").html(html); alert(html); } , complete:function(html){ $("#form_resp_ajax .btn").html(old_text); $("#form_resp_ajax .btn").addClass("disabled").attr("disabled",false); } });
ev.preventDefault(); }); $(document).on("mouseenter", "#productRate", function(e){ $(this).append("<span></span>"); } ); $(document).on("mouseover", "#productRate", function(e){
if (!e) e = window.event; if (e.pageX){ x = e.pageX; } else if (e.clientX){ x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft; } var posLeft = 0; var obj = this; while (obj.offsetParent) { posLeft += obj.offsetLeft; obj = obj.offsetParent; } var offsetX = x-posLeft, modOffsetX = 5*offsetX%this.offsetWidth; rating = parseInt(5*offsetX/this.offsetWidth); if(modOffsetX > 0) rating+=1; $(this).find("span").eq(0).css("width",rating*30+"px"); $("#rating-label_0").css("display","none"); for (i=1;i<=5;i++){ $("#rating-label_"+i).css("display","none"); } $("#rating-label_"+rating).css("display","block"); } ); $(document).on("mouseout", "#productRate", function() { $(this).find("span").remove(); for (i=1;i<=5;i++){ $("#rating-label_"+i).css("display","none"); } $("#rating-label_0").css("display","block"); } ); $(document).on("click","#productRate", function(){ get_obj("o_resp").value = rating; $(this).find("div").eq(0).css("width",rating*30+"px"); $("#rating-label_0").css("display","none"); return false; });
<div id="productRate"> <div id="select_stars" ></div> </div>
|
До того как было Hover все хорошо работало (((( |