Сообщение от skrudjmakdak
|
document.querySelectorAll('a[href=' + window.location.pathname + ']')
|
Сообщение от skrudjmakdak
|
document.querySelector('a[href="/forum/"]').className = 'selected'
|
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<style type="text/css">
.red{
background-color: #CC0000;
}
</style>
</head>
<body>
<a href="/lookatcode.com/">this</a>
<a href="/param-pam-pam">that</a>
<script>
var list = document.querySelectorAll('a'),
a, h;
for (var i = 0; i < list.length; ++i)
{
a = list[i];
h = a.getAttribute('href');
if(location.href.indexOf(h) != -1) a.classList.add('red')
}
</script>
</body>
</html>