0
我有一個popup.html,它加載了jquery,然後是popup.js。我試圖改變光標,當我將鼠標懸停在某個類上的div上時,這種情況沒有發生。jQuery事件處理程序在Chrome中不起作用popup.js
popup.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<link type="text/css" rel="stylesheet" href="css/fbh-ui.css" />
<script type="text/javascript" src="js/jq.js"></script>
<script type="text/javascript" src="js/popup.js"></script>
</head>
<body style="width: 200px">
<div id="fbh-main">
<div class="fbh-popup-menu-item" id="fbh-popup-enabled"></div>
</div>
</body>
popup.js
$(document).ready(function() {
$('.fbh-popup-menu-item').mouseenter(function() {
this.css('cursor', 'pointer');
});
$('.fbh-popup-menu-item').mouseleave(function() {
this.css('cursor', 'default');
});
});
此代碼應工作。 DOM元素已經存在,所以沒有理由不這樣做。
噢該死的,我不能相信我這樣做。 :)我在我的擴展中的每個其他JS頁面中都有$(this)。謝啦! – gdanko 2013-02-10 05:27:12