懸停不起作用。我測試這火狐19.0,Cometbird 11.0,瀏覽器9(Firefox,Cometbird,Explorer)當元素由javascript/jquery製作時,懸停不起作用
我測試工作的唯一瀏覽器Chrome的是25
這段代碼呢?
首先,當鼠標懸停到元素#wrap_req時,它將調用一個函數,告訴在#wrap_req中添加html內容。
<span id='cancelReq' ></span>
然後當鼠標懸停到元素#cancelReq時,該元素的背景必須更改。
<script language="JavaScript">
function mOver(x)
{
var txt = 'cond1'; //let's say it this way to satisfies the IF
if(txt == 'cond1')
{
var txt2 = "<span id='cancelReq' ></span>";
$('#wrap_req').html(txt2);
$('#cancelReq').css('display', x);
}
}
</script>
CSS
<style>
#wrap_req{width:193px; margin:0 auto; border:1px solid red;}
#cancelReq{display:none; background-image:url(../images/cancel.png); }
#cancelReq:hover{background-image:url(../images/cancel2.png);}
</style>
HTML
<div id='wrap_req' onmouseover=\"mOver('block')\" onmouseout=\"mOver('none')\" >
</div>
我嘗試添加下面的代碼到功能動機(),if語句裏面。
如果我添加alert(),它工作正常。背景圖像改變。
但我不需要使用alert();
$('#cancelReq').hover(
function
{
//alert('entered Friends');
$('#cancelReq').css('background', '#eeeeee');
}
);
哪裏是'unFriend'元素?你可以在http://jsfiddle.net – 2013-03-01 03:24:02
@ArunPJohny創建演示對不起,我做了一個錯誤的複製/粘貼。 unFriend必須是「cancelReq」。我更新了我的問題。謝謝 – 2013-03-01 03:25:45
你在Firefox中測試它,如果是的版本 – 2013-03-01 03:26:31