Avatar of Jamie
Jamie
Flag for United Kingdom of Great Britain and Northern Ireland

asked on 

Open grouped links on a page in new tabs via jquery

Hello Experts,

If I have a number of grouped links on a page - how can I automatically open then into new tabs by a press of a button.

e.g.

<script>
$('#ButtonOne').click(function() {
    $('a').each(function() {
        window.open($(this).attr('href'));
    });
});
</script>

<a id="group1" href="page1.html">Click Here</a><br />
<a id="group1" href="page2.html">Click Here</a><br />
<a id="group1" href="page3.html">Click Here</a><br />
<a id="group2" href="page4.html">Click Here</a><br />

<button type="button" id="group1">Open Links</button> - should only open page1.html, page2.html, page3.html
<button type="button" id="group2">Open Links</button> - should only open page4.html

Many thanks

Jamie
jQueryJavaScript

Avatar of undefined
Last Comment
Michel Plungjan

8/22/2022 - Mon