Javascript jQuery:在跨度上触发点击事件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3590243/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
jQuery: Fire click on event on a span
提问by NinjaCat
I saw a post earlier today and have been playing around with: http://arashkarimzadeh.com/index.php/jquery/7-editable-jquery-plugin.html
我今天早些时候看到一个帖子,一直在玩:http: //arashkarimzadeh.com/index.php/jquery/7-editable-jquery-plugin.html
What I'd like to be able to do is when a span gets clicked, to fire the click event on a different element in the page:
我希望能够做的是当一个跨度被点击时,在页面中的不同元素上触发点击事件:
<div class='editable sampleItem pointer' id='qqq'>click me!!!</div>
Is that possible?
那可能吗?
回答by Moin Zaman
sure..
当然..
$('.myspan').click(function(){
$('.different-div').click();
})
$('.different-div').click(function(){alert('div click fired')});
回答by Srinivasan.S
Check like this,
像这样检查,
HTML:
HTML:
<div class='editable sampleItem pointer' id='qqq' onclick='clickHandler()'>click me!!!</div>
Javascript:
Javascript:
<script type="text/javascript">
function clickHandler() {
/* You code here */
}
</script>

