JSFiddle - React, Tailwind, and code Playground

http://stackoverflow.com/questions/6853203/jquery-checkbox-target-blank

by tw16

HTML

<div id="wanted">
    <a href="#">Test Link 1</a>
    <a href="#">Test Link 2</a>
</div>
<div id="unwanted">
    <a href="#">Test Link 3</a>
    <a href="#">Test Link 4</a>
</div>
<input type="checkbox" id="newtab" /><label for="newtab">Open links in new tab</label>

CSS

div{margin-bottom: 10px;}
#wanted a{color: blue;}
#unwanted a{color: red;}

JavaScript

$(function () {
    $('#newtab').click(function () {
        if ($(this).is(':checked')) {
            $('#wanted a').attr('target', '_blank');
        } else {
            $('#wanted a').removeAttr('target');
        }
    });
});