簡體   English   中英

jQuery:Fire點擊跨度上的事件

[英]jQuery: Fire click on event on a span

我今天早些時候看過一篇文章並一直在玩: http//arashkarimzadeh.com/index.php/jquery/7-editable-jquery-plugin.html

我希望能夠做的是點擊一個跨度,在頁面中的另一個元素上觸發click事件:

<div class='editable sampleItem pointer' id='qqq'>click me!!!</div>

那可能嗎?

當然..

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

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

像這樣檢查,

HTML:

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

使用Javascript:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM