JavaScript jQuery Basics Working with jQuery Collections Changing Element Properties

Antonio De Rose
Antonio De Rose
20,857 Points

same code, does not open in a new window

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

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

Saqib Ishfaq
Saqib Ishfaq
13,911 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

Steven Parker
Steven Parker
176,634 Points

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

Antonio De Rose
Antonio De Rose
20,857 Points

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