简体   繁体   中英

Update URL with JavaScript doesn't work

I'm trying to change the url of some tag using another one. Can't get it to work. Please help.

Here's my code:

<a href="#" rel="wd" onclick="updateUrl('wd')">Category</a>

<a id="test" href="index.php?path=portfolio/web" class="thumbnail"><img src="img.jpg"></a>

<script type="text/javascript">
function updateUrl(newUrl)
{
    document.links["test"].href .= newUrl;
}
</script>
document.links['test'].href += newUrl;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM