Anis Rétro Anis Rétro - 1 year ago 76
HTML Question

Change content of the page with anchor

Actually making a website and searching to focus the id footer by using anchor but I wanna change the background color of the footer when anchor has been clicked (I already know that there is a way to do it with jQuery but I'm not using jQuery, only native javascript)

<a id="footer"></a>
<div class="footer">
Mail address: <a href="mailto:hidden for example">hidden for example</a> <i class="material-icons">mail_outline</i><br />
Skype: <a href="hidden for example">hidden for example</a> <i class="material-icons">chat_bubble_outline</i>
<br /><br />
<span style="font-size: 16px;font-weight: bold;color: black;font-family: 'Raleway', sans-serif;">An original idea from hidden for example</span>

Answer Source

Put this in your click event callback



document.querySelector(".footer").style.backgroundColor = "red";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download