Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

Enable Disable Hyperlinks using jQuery or Disable Particular Div of Hyperlinks in jQuery

Jul 21, 2013
Introduction

Here I will explain how to disable hyperlinks using jQuery or Enable / disable hyperlinks using jQuery.

Description:


Disable hyperlinks in div

To disable particular link or particular div block of hyperlinks we need to write the code like as shown below


$('#lnkhome').click(function(e) {
e.preventDefault();
});
// Disable Particular div block hyperlinks
$('#linksdiv a').click(function(e) {
e.preventDefault();
});
If you want to see it in complete example check below code


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Disable Hyperlinks using jQuery</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
$(function() {
// Disable Particular Hyperlink
$('#lnkhome').click(function(e) {
e.preventDefault();
});
// Disable Particular div block hyperlinks
$('#linksdiv a').click(function(e) {
e.preventDefault();
});
})
</script>
</head>
<body>
<b>Disable Particular Link</b><br />
<a href='http://www.google.com' id="lnkhome">Google</a><br />
<b>Disable Particular DIV Block Links</b><br />
<div id="linksdiv">
<a href='http://www.facebook.com' id="lnkfacebook">facebook</a>
<a href='http://www.gmail.com' id="lnkgmail">gmail</a>
<a href='http://www.aspdotnet-suresh.com' id="lnkaspdotnet">Aspdotnet-Suresh</a>
<a href='http://www.yahoo.com' id="lnkyahoo">yahoo</a>
</div>
</body>
</html
Live Demo

For live demo click on below links and see whether those links redirect to another page or not


Disable Particular Link
Google

Disable Particular DIV Block Links

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

3 comments :

Unknown said...

nyc

Anonymous said...

please some one expalin function(e) what e contains i am new to jquery

Anonymous said...

but with new tab.., open de url

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.