Hi There,
do it like this, with the use of a regular expression:
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Tooltip demo</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="http://ara-abcarians.com/jquery/atooltip/js/jquery.atooltip.js"></script>
<link type="text/css" href="http://ara-abcarians.com/jquery/atooltip/css/atooltip.css" rel="stylesheet" media="screen" />
<script>$(function(){$('a.normalTip').aToolTip(); });</script>
</head>
<body>
<div id="container" style="width:600px; margin: 0 auto; padding-top:50px;">
<div id="left column">
<p>
TSD Lorem ipsum TSD dolor sit amet, consectetur adipisicing elit, TSD-1a sed do eiusmod tempor incididunt ut labore
et dolore magna aliqua. Ut TSD-1a enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo consequat. Duis TSD-1a aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur TSD-1a sint occaecat cupidatat non TSD, proident, TSD-1a sunt in culpa qui officia deserunt
mollit anim id est TSD TSD-1a laborum TSD.
</p>
</div>
</div>
<script>
//Matches (start of line or whitespace)(TSD)(whitespace, or a fullstop, or a comma, or the end of the line)
var tsd = /(^|\s)(TSD)(\s|\.|,|$)/g;
var tsdTip = '$1<a href="#" class="normalTip" title="TSD">$2</a>$3'
//Matches (start of line or whitespace)(TSD-1a)(whitespace, or a fullstop, or a comma, or the end of the line)
var tsd1a = /(^|\s)(TSD-1a)(\s|\.|,|$)/g;
var tsd1aTip = '$1<a href="#" class="normalTip" title="TSD-1a">$2</a>$3'
$('#container').html(
$('#container').html().replace(tsd, tsdTip).replace(tsd1a, tsd1aTip)
);
</script>
</body>
</html>
Bookmarks