简体   繁体   中英

Trigger onclick event within onclick javascript or jquery?

Is it possible to trigger another onclick event upon clicking on a button?

ie

onclick="document.getElementById('link').onclick()"

I'm trying to get this working in ie6.

Tried the jquery script but no luck in ie6:

<textarea style="height:80px; border:0px;" name="box3" id="box3" cols="58" rows="7" class="title">FUTURE: </textarea> 
<script> $('#box3').click(function() { $('#link').click(); }); </script> 
<a id="link"><div id="test3-header" class="accordion_headings future" >FUTURE</div></a>

Yes. It's easiest using jQuery:

$('#buttonActuallyClicked').click(function() {
    $('#buttonBeingFakeClicked').click();
});

This will "fake" a click on the element with id buttonBeingFakeClicked whenever someone clicks on the element with id buttonActuallyClicked .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM