1

At the top of web page I have a script so links don't work on the page.

<head>
   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<script>
        $(document).ready(function () {
            $('.portfolio-featured-image, .portfolio-entry-title').click(function () {
                return false;
            });
        });
    </script>

Is there a way to make one particular link on the page not obey the script? For example make one of the page's many <a href="url">link text</a> a working clickable link but have all the others obey the script and be non-clickable?

1
  • 1
    There's two places you could do it: either change the jQuery selector so that it doesn't include whichever link you don't want disabled, or add some logic into the callback to return something other than false if the click was on the live link, which would likely mean evaluating the click event. Commented Jun 12, 2020 at 19:17

1 Answer 1

1

add an id to the link you want to exclude from the script like: id="link"

 $(document).ready(function () {
        $('.portfolio-featured-image, .portfolio-entry-title').click(function () {
            if($(this).attr('id') == "link") return true;
            else return false;
        });
    });
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.