Search code examples
jqueryhref

Find link href value # and add class


i am facing a problem. In my project some href value has a link and some are #.when i trying to mouse hover then css mouse property cursor pointer. I want to add class when a href value are # so that after mouse hover cursor default I want to find all link href which value are #.

if href value is # then add class else remove class on every page change.

i am trying to solve but something mistake that i am not find...

here is my code

$('body').on('change', function() {

   $(this).find('[href="#"]').addClass('cusrorDefault');

}

please help me to solve this problem


Solution

  • You do not need to use jQuery Using CSS, you can easily solution this problem in all pages

    a[href="#"]
    {
      text-decoration: none;
      cursor: default;
     }
    <a href="#">Link</a>
    <a href="https://stackoverflow.com/">Link</a>
    <a href="#">Link</a>
    <a href="https://stackoverflow.com/">Link</a>