0

I have html like this (note -: I included j library on the top of page )

 <div class="WIWC_T1">
    <a href="javascript:void(0);" onClick="call_levelofcourse();popup('popUpDiv1')">Level of Course</a>
 </div>

to make it not clickable i used jquery like this

$(".WIWC_T1 a").click(function(){
    return false ;
});

i tried this too

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

but onClick="call_levelofcourse();popup('popUpDiv1')" is still working on my page . what is soltuion to do it in very simple way ??

Vipul sharma
  • 1,245
  • 1
  • 13
  • 33

6 Answers6

4

Another aproach (which not uses jQuery) is to use css class:

.disable-anchor{
  pointer-events: none;
  cursor: default;
}

and then just add this class to your anchor like:

<a href="javascript:void(0);" 
   class="disable-anchor"     
   onClick="call_levelofcourse();popup('popUpDiv1')">
    Level of Course
</a>

P.S. check the availability of pointer-events before using it because this is the CSS3 feature.

Nicolai
  • 1,907
  • 1
  • 23
  • 31
1

Try this

$(".WIWC_T1 a").click(false);
Janitha Tennakoon
  • 856
  • 11
  • 40
1

To prevent events, like a when clicking, prevent that event like this:

$(".WIWC_T1").on("click", function(e)) {
    e.preventDefault();
    //Do your code, such show a popup
}
Zander
  • 1,076
  • 1
  • 9
  • 23
0
<a href="javascript:void(0);" onClick="call_levelofcourse();popup('popUpDiv1')" class="unclickable">Level of Course</a>



function call_levelofcourse(){
if(!$("a").hasClass("unclickable")){
 /* your codes here */
}
}
v.orujov
  • 46
  • 1
  • 5
  • your method can work but i have more a tags with in same class and every one have different onclick function ... so i cant use your solution for every a tag – Vipul sharma Feb 13 '15 at 07:08
  • you can select anchor with $(".WIWC_T1>a") or give an exact id to the anchor. And also can try $(this) selector – v.orujov Feb 13 '15 at 07:52
  • Could you please [edit] in an explanation of why this code answers the question? Code-only answers are discouraged, because they don't teach the solution. – Scimonster Feb 13 '15 at 09:19
0
$(".WIWC_T1 a").on("click", function(){ 
   $(this).attr("onClick", false); 
});

Please remember to add Jquery prototype Thanks Vivek

Vivek Gupta
  • 955
  • 4
  • 7
0
 $(".WIWC_T1 a").removeAttr('onclick');
Vimal Vataliya
  • 260
  • 4
  • 15