admin管理员组文章数量:1334309
I have
<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>
I want to make click on the element that rises when onmouseover="artifactAlt(this,event,2)"
is firing, how to do that?
When I am doing $('#body').contents().find('td[art_id="4949"]')[0].click();
i get undefined
and nothin happens.
I have
<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>
I want to make click on the element that rises when onmouseover="artifactAlt(this,event,2)"
is firing, how to do that?
When I am doing $('#body').contents().find('td[art_id="4949"]')[0].click();
i get undefined
and nothin happens.
- 4 What hidden element? I don't see any hidden elements above (no pun). – T.J. Crowder Commented Feb 5, 2017 at 14:13
2 Answers
Reset to default 7You should use .click()
method.
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./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>
You should try jquery trigger's as follows
function artifactAlt(element, event, number) {
$(element).trigger('click');
}
Usage of trigger('click') will save you one function call as jQuery internally calls trigger for a $().click() function call as pointed out in this post.
本文标签: javascriptJquery click on hidden elementStack Overflow
版权声明:本文标题:javascript - Jquery click on hidden element - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742367971a2461671.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论