[JS] Not well known link() method
Probably every jQuery developer know how to create link with it:
$('<a href="http://google.com"/>').text('Google');
or:
$('<a href="http://google.com">Google</a>');
But there's also a little know link() method:
'Google'.link('http://google.com');
Written by Kasper Mikiewicz
Related protips
3 Responses
Interesting find! Is there a spec for the function somewhere? I wonder what's the browser support...
over 1 year ago
·
Wow!
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
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Javascript
Authors
Related Tags
#javascript
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#