A19*_*919 1 html javascript jquery events
我有
<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>
Run Code Online (Sandbox Code Playgroud)
我想点击onmouseover="artifactAlt(this,event,2)"发射时升起的元素,怎么做?
当我在做的时候 $('#body').contents().find('td[art_id="4949"]')[0].click();
我得到了undefined,没有发生.
你应该使用.click()方法.
function artifactAlt(obj,event,number){
$(obj).click();
}
Run Code Online (Sandbox Code Playgroud)
function artifactAlt(obj,event,number){
$(obj).click();
}
$('tr').click(function(){
alert('tr clicked');
});Run Code Online (Sandbox Code Playgroud)
<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>Run Code Online (Sandbox Code Playgroud)