I have an html snippet:
<div class="wc-social-login form-row-wide">
<a href="http://www.example.com/wc-api/auth/twitter/? return=http://www.example.com" class="button-social-login button-social- login-twitter"><span class="si si-twitter"></span>Connect with Twitter</a>
<a href="http://www.example.com/wc-api/auth/facebook/?return=http://www.example.com" class="button-social-login button-social-login-facebook"><span class="si si-facebook"></span>Connect with Facebook</a>
</div>
I need to add a target element to the anchor tags, this is inside wordpress.
I tried this with jquery:
jQuery(document).ready(function ($) {
$('.wc-social-login form-row-wide a').each(function () {
$(this).attr('target', '_blank');
});
});
Any inputs on how to add a target attribute to both the tags inside the div will be very helpful.
You don’t need to use
each()
. Also your selector is wrong use.wc-social-login.form-row-wide
instead of.wc-social-login form-row-wide
like following.