Click here to Skip to main content
15,884,237 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to disable a tag in my page using jquery, i try a lot. but i can't find expected result please help.

my code is
JavaScript
$("#li2 a").attr('disabled', 'disable');
$("#li2 a").prop('disabled', true);


thanks in advance.
Posted
Updated 31-Mar-15 2:24am
v2
Comments
King Fisher 31-Mar-15 8:25am    
what is your Tag?
Peter Leow 31-Mar-15 10:25am    
Are you trying to prevent a hyperlink from working?

 
Share this answer
 
HTML
<ul id="tabnav">

        <li id="tab_a" class="tab1"><a href="tab1.htm">Tab a</a></li>
        <li id="tab_b" class="tab2"><a href="tab2.htm">Tab b</a></li>
        <li id="tab_c" class="tab3"><a href="tab3.htm">Tab c</a></li>
    </ul>



document.getElementById("tab_c").childNodes[0].onclick = function() {return false;};


use this concept. I hope working fine!!!!!!!!!!!!
 
Share this answer
 
v2
Try this:
C#
$("#li2 a").click(function(e) {
        // disable the default behavior 
        e.preventDefault();
    });

Refer: http://api.jquery.com/event.preventdefault/[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900