Hi is there any way to emulate a click on a span when an user click’s an image in another location of the page? Can you use for example
<div id="g1">
<span>hey</span>
<span>second hey</span>
</div>
<div id="a2">
<img id="img" src="....."/>
</div>
<script type="text/javascript">
$(document).on('click', '#img', function(){
$('#g1 > span:first-child').trigger('click');
Will this work or is there any other form to emulate the click on the first span when the user clicks the image?
What if the span you need is in an iframe and the image clicked is outside the iframe?
Yes it will work, i created fiddle at http://jsfiddle.net/De9Z6/
You can use
trigger('click')orclick()either.