Last Updated: October 11, 2021
· idered

[JS] Not well known link() method

Probably every jQuery developer know how to create link with it:

$('<a href=""/>').text('Google');


$('<a href="">Google</a>');

But there's also a little know link() method:


3 Responses
Add your response

Interesting find! Is there a spec for the function somewhere? I wonder what's the browser support...

over 1 year ago ·


W3Schools says it's supported in "All Major Browsers". A quick test in Firefox, IE7, and Chrome shows it works in all of those.

I never expected a method like that on the String object. It's very Pythonic...

over 1 year ago ·

There are many other HTML wrapper methods in JS besides just link() too.

over 1 year ago ·