我有頁a產品和它的圖像加載在一個表中。圖像最初是隱藏的,onmouseover我想顯示圖像。圖像是在div標籤內,產品名稱顯示爲link.In的onready功能,我的事件處理程序附加到鏈接,jquery - 訪問一個元素是給零null
$('a').each(function()
{
if($(this).attr('id').match(/prod/))
{
$(this).mouseover(display());
}
});
,並在事件處理程序(一個函數調用顯示)我打電話
function display()
{
$('div').each(function()
{
if($(this).attr('id').match(/sx/))
{
alert("hi")
}
});
}
但是,我出現錯誤$(「div」)爲空
HTML是:
<table>
<tr><td><a href="link">product name</a></td>
<td><div class='.hidden'><table><tr><td><img src=""></img></td></tr></table></div></td></table>
什麼是你的HTML? – 2010-08-02 07:14:12
更新我的帖子進一步 – 2010-08-03 08:49:07