JavaScript jQuery Basics Working with jQuery Collections Changing Element Properties

Antonio De Rose
Antonio De Rose
20,865 Points

same code, does not open in a new window

const $secureLinks = $('a[href^="https://"');

$secureLinks.attr('target','_blank')

Saqib Ishfaq
Saqib Ishfaq
13,912 Points

just to add you forgot closing square bracket there.... const $secureLinks = $('a[href^="https://"]'); and a semi colon to end the 2nd statement.... $secureLinks.attr('target','_blank');

it might work without these but just incase:)

2 Answers

Antonio De Rose
Antonio De Rose
20,865 Points

it is working now, thanks anyway., what I did was CTRL + F5

Steven Parker
Steven Parker
195,302 Points

This code seems to be OK, but what's the HTML look like that it works on?