Gomzy Gomzy - 1 year ago 31
jQuery Question

how to trigger all anchor tags on click of a button?

sorry if title is wrong

i want to open all the links on a single click

thank you in advance


<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

<a href="1.link">test</a>
<br />
<a href="2.link">test2</a>
<input type="button" id="bb" value="click">



Try like following.

$("#bb").click(function () {
    $('a').each(function() {
        window.open($(this).attr('href'), '_blank');