StackOverflow Question: Clean Anchor Tag

http://stackoverflow.com/q/25049680/1093087

by klenwell

HTML

<div id="right-slide"></div>

JavaScript

function specialsLink(text, url) {
  var $h1 = $('<h1 />').text(text);
  var $a = $('<a />').attr('href', url).html($h1);
  return $a;
}

$('div#right-slide')
  .append(specialsLink('Click Here for Limited',
    'http://example.com/limited-specials/'))
  .append(specialsLink('Time Specials',
    'http://example.com/limited-specials/'));