我有
<table width="60" height="60" cellpadding="0"
cellspacing="0" border="0" style="float: left; margin: 1px"
background="images/data/source_red.gif">
<tbody>
<tr>
<td act1="7" act3="8" store="true" art_id="4949" cnt="1" div_id="AA_4949"
onmouseover="artifactAlt(this,event,2)"
onmouseout="artifactAlt(this,event,0)"
valign="bottom"
style="background-image: url("images/d.gif"); cursor: pointer;"> </td>
</tr>
</tbody>
</table>
我想点击onmouseover="artifactAlt(this,event,2)"
触发时上升的元素,该怎么做?
我正在做$('#body').contents().find('td[art_id="4949"]')[0].click();
我得到undefined
并且没有发生。
答案 0 :(得分:5)
您应该使用.click()
方法。
function artifactAlt(obj,event,number){
$(obj).click();
}
function artifactAlt(obj,event,number){
$(obj).click();
}
$('tr').click(function(){
alert('tr clicked');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table width="60" height="60" cellpadding="0"
cellspacing="0" border="0" style="float: left; margin: 1px"
background="images/data/source_red.gif">
<tbody>
<tr>
<td act1="7" act3="8" store="true" art_id="4949" cnt="1" div_id="AA_4949"
onmouseover="artifactAlt(this,event,2)"
onmouseout="artifactAlt(this,event,0)"
valign="bottom"
style="background-image: url("images/d.gif"); cursor: pointer;">abcd</td>
</tr>
</tbody>
</table>
答案 1 :(得分:0)