Rss Feed Tweeter button Facebook button Technorati button Reddit button Linkedin button Webonews button Delicious button Digg button Flickr button Stumbleupon button Newsvine button

A Waage Blog

Ruby, Rails, Life

Archive for the ‘Javascript’ Category

Create a link in Javascript with the .link method

without comments

Now I don’t claim to be a Javascript expert, but I thought I knew the basics pretty well! Here’s a little-known method built into Strings that creates a link tag:

html = 'click me'.link('http://example.com')

which results in:

html = '<a href="http://example.com">click me</a>'

Written by Andrew Waage

May 22nd, 2011 at 12:11 pm

Posted in Javascript

Tagged with , ,