Reputation: 443
That's what I have: <a href="<?=$arItem["LINK"]?>"><?=$arItem["TEXT"]?></a>
. <?=$arItem["LINK"]?>
- it's an array, which contains some links. I need to add an extra hashtag parameter #nav-link
to the end of each link. That's how I tried do it, but this code doesn't work:
<a id="likeLink" href=""><?=$arItem["TEXT"]?></a>
<script>
$(document).ready(function () {
$("#likeLink").attr("href", <?=$arItem["LINK"]?> + "#nav-link");
});
</script>
I don't know PHP quite well, but I think I need to add new array and return there all necessary links with hashtag and use this array in href
.
Thanks for help!
Upvotes: 0
Views: 93
Reputation: 637
You have to give your php to javascript into a javascript string:
$("#likeLink").attr("href", "<?=$arItem["LINK"]?>#nav-link");
Upvotes: 1
Reputation: 497
It's hard to say without knowing more but it looks like you need quotes around the link on this line:
$("#likeLink").attr("href", "<?=$arItem["LINK"]?>" + "#nav-link");
Upvotes: 0