Jquery ile aktif olan linke css atama
14 Ocak 2020 / 23:00
Burak
Merhaba arkadaşlar,
Websitesinde o anda aktif olan linki fontunu değiştirme isteyebiliriz. Misal Kategori 1 de ise menu yazısı kalın olsun gibi şeyler, bunun için aşağıdaki kodları kullanabilirsiniz.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <style> a { color: Red; } a:active { color: blue; } a:visited { color: gray; } a:hover { color: yellow; } .active { font-weight: bold; } </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.js"></script> </head> <body> <div class="headerlinks" id="headerlinks" name="headerlinks"> <a href="/test2.html">Test 2</a> <a href="/test1.html">Test 1</a> </div> <script> $(document).ready(function () { $(".headerlinks>a").each(function () { if (this.href == window.location.href) { $(this).addClass("active"); } }); }); </script> </body> </html> |
Etiketler: jquery active link css
Bu Yazılarıda Okuyabilirsiniz...
Bir cevap yazın