tester33,
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
</style>
<script>
window.addEventListener('DOMContentLoaded', function() {
[].forEach.call( document.querySelectorAll('span.affiliate'), function(el) {
var a = document.createElement('a');
a.classList.add('affiliate');
a.text = el.textContent;
a.setAttribute('href', el.title);
el.parentNode.replaceChild(a, el);
});
});
</script>
</head>
<body>
<span class="affiliate" title="1.html">текст1</span>
<span class="affiliate" title="2.html">текст2</span>
<span class="affiliate" title="3.html">текст3</span>
</body>
</html>