So I have a looping example of site url string and trying to add pages to the links, but I don’t want to have to deal with the domain as it’s fixed. Right now it doesn’t work.. but I’m trying to fix it.
<script>
$(document).ready(function() {
url = $(this).attr('href', $(this).attr('href'));
$('#sitemap a').attr('href','http://site.com/?c=123&p='+url);
});
</script>
// trying to get output http://site.com/?c=123&p=page1.html
<div id="sitemap">
<a href="page1.html">test</a>
<a href="page2.html">test</a>
<a href="page3.html">test</a>
</div>
So what you wan to do is actually:
In this line of code that you wrote,
thisactually refers todocument. Anddocumentdoesn’t have an attribute calledhref.