Does anyone have any idea how I can do this? I want my content writer to be able to add span classes to certain numerical amounts that then automatically hyperlink to a pre-defined URL. Example:
And the price at John's hardware shop are<span class="john-shop">$2.35</span>
Can this be done with php or even css?
Grateful for any help.
desired outcome:
And the price at John's hardware shop are <a href="http://www.johns-shop.com"><span class="john-shop"> $2.35</span></a>
Ok, after much trial and error, this code works. Hope it helps someone else. The "link.js" contains this code:
$( document ).ready(function() {
$('.john-shop').contents().wrap('<a href="http://www.johns-shop.com"></a>');
});
and this is the test html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en">
<head>
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="js/link.js"></script>
<title></title>
</head>
<body>
And the price at John's hardware shop are<span class="john-shop">$2.35</span>
</body>
</html>