开发者

jQuery: Fire click on event on a span

开发者 https://www.devze.com 2023-01-13 18:03 出处:网络
I saw a post earlier today and have been playing around with: http://arashkarimzadeh.com/index.php/jquery/7-editable-jquery-plugin.html

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

精彩评论

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