开发者

jQuery: Fire click on event on a span

I saw a post earlier today and have been playing around with: 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:

开发者_如何学JAVA<div class='editable sampleItem pointer' id='qqq'>click me!!!</div>

Is that possible?


sure..

$('.myspan').click(function(){
   $('.different-div').click();
})

$('.different-div').click(function(){alert('div click fired')});


Check like this,

HTML:

<div class='editable sampleItem pointer' id='qqq' onclick='clickHandler()'>click me!!!</div>

Javascript:

<script type="text/javascript">
function clickHandler() {
    /* You code here */
}
</script>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜