2

i need to disable the anchor tag below.. am using this coding :( but it doesn't help me

jquery:-

$("a.lookupclick").addClass("viewDisabled");
$(".DeleteRow").addClass("viewDisabled");
$(".viewDisabled").prop('disabled', true);

or

$(".lookupclick").attr("disabled","disabled");

it works sometimes ,but most of the times it didn't works.. Y? how to prevent to click th

HTML :-

<div class="panel1">
  <a tabindex="1" disabled="" class="lookupclick" id="departmentpopup" href="#lookupform" >
     <img class="ImgSearch1" alt="Search" src="/Images/.jpg">
  </a>
</div>
1

4 Answers 4

3

You could do:

$("a.lookUpClick").on("click", false);

And then:

$("a.lookUpClick").off("click");

to reactivate them.

Thank you Washington Guedes for the suggested 'golfing'!

Sign up to request clarification or add additional context in comments.

1 Comment

you can just use: $("a.lookUpClick").on("click", false); ... +1 for nice idea... here is a live example: jsfiddle.net/oeppsk4n
1

You can just prevent default function of the link:

$('a.lookupclick').click(function(e)
{
   e.preventDefault();
});

If you want to know the difference between return false and preventDefault take a look at this question - event.preventDefault() vs. return false

Comments

1

Try:

$("a.lookupclick").attr('href','');

1 Comment

That prevents the link from being enabled.
0

You can do this a couple of ways. You could listen for click events on the link and use the preventDefault() method to stop the event.

$('a.lookupclick').click(function(event){
    event.preventDefault();
});

Another option is that you can make the href attribute of the links javascript:; which will cause the links to be clickable but not do anything. If you need to do this with jQuery you could do it as such:

$('a.lookupclick').attr('href','javascript:;');

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.