Using javascript or jquery what would be the best way to simulate a click on live video inside div id 1.
Im not sure how to handle this when the <a> does not have a id attribute.
<div id='1'>
<a href="#" class="edit-settings">Edit Settings</a>
<a href="javascript:void(0);" class="live_video">Live Video</a>
</div>
<div id='2'>
<a href="#" class="edit-settings">Edit Settings</a>
<a href="javascript:void(0);" class="live_video">Live Video</a>
</div>
Advertisement
Answer
To trigger the click on the first link.
$("#1 > a:first").trigger('click');
To trigger the click on the second link.
$("#1 > a:last").trigger('click');
You do have CSS classes you can use as well.
$("#1 > a.live_view").trigger('click');
NOTE: a DOM ID can not start with a number.