JSFiddle - React, Tailwind, and code Playground
by rodrigonery
HTML
<a id="google" href="http://www.google.com">Google</a><p>
<a id="facebook" href="http://www.facebook.com">Facebook</a><p>
<!-- Normal Link without jQuery-->
<a href="http://www.yahoo.com.br" id="yahoo">Yahoo</a>
CSS
p {
margin-top: 5%;
}
JavaScript
/*
$(function () {
$("#google").attr("target", "_blank");
$("#facebook").attr("target", "_blank");
});
*/
// With .prop();
/*
$(function () {
$("#google").prop("target", "_blank");
$("#facebook").prop("target", "_blank");
});
*/
// Awesome? :x
// javaScript pure
var yahoo = document.getElementById("yahoo");
var facebook = document.getElementById("facebook");
var google = document.getElementById("google");
var a = document.getElementsByTagname("a");
a.onclick = (function() {
yahoo.setAttribute("target", "_blank");
facebook.setAttribute("target", "_blank");
google.setAttribute("target", "_blank");
});