Hello!

It is necessary when you click on the link to make it active, to tint the background. Do so

$(document).ready(function () { $('.j-links').click(function () { $(this).addClass('active'); }); }); 

In css, that's what

 .links .j-links.active { background-color: orange; color: #2f8bd8; } 

On the page itself

 <div class="links"> <a class="j-links" href="report.php"> Отчет </a> <a class="j-links" href="statistics.php"> Статистика </a> </div> 

This solution does not work ..

Changed links to paragraphs p - the class active is hung .. but it is necessary and the transition to the address .. and for this you need links .. (

  • one
    Change the tag to javascript, javascript is not java;) otherwise nobody will answer you from the target audience. - Kobayashi_Maru
  • @ Anna, To format the code, select it with the mouse and click on the button 101010 of the editor. - Nicolas Chabanovsky
  • one
    The question is what? Or did you brag about your decision?)) - Vitalii Maslianok
  • that this decision does not work .. - Anna
  • 3
    and in general it would be nice for you to close all your current issues, which have been collected a lot in the last 2 days ... - Vitalii Maslianok

2 answers 2

Is the link moving, is the new page loading? If so, you need to use the pseudo-class active . Replace your CSS with the following:

 .links aj-links:active { background-color: orange; color: #2f8bd8; } 

PS "and remove the script)" - @Gautama -Buddha

  • 3
    and remove the script) - Gautama Buddha

In this form, nothing will work ... the page is updated ... if you loaded something like this without rebooting, it would work ...

 $(document).ready(function () { $('.j-links').click(function () { $(this).addClass('active'); return false; }); }); 

will change but the transition to the page will not be