June 7, 2010

Remove Links and Display Text using jQuery




Here is a simple example of how to remove all links on a page and display Text instead

<html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
title>Remove Links</title>
<
script type="text/javascript"
src="http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.2.min.js">
</
script>
<
script type="text/javascript">
$(function() {
$('#btnRemove').click(function() {
$('a').contents().unwrap();
});
});
</script>
</
head>
<
body>
My Sites: <br /><br />
<
a href="http://www.dotnetcurry.com">DotNetCurry</a><br />
<
a href="http://www.devcurry.com">DevCurry</a><br />
<
a href="http://www.sqlservercurry.com">SQLServerCurry</a><br />
<
br />
<
input id="btnRemove" type="button" value="Remove Links" />
</
body>
</
html>

Before

image

After clicking the Button

image


See a Live Demo



'Like' us on our FaceBook page if you find this blog useful. Thanks!


Did you like this post?
kick it on DotNetKicks.com Save on Delicious
subscribe via rss subscribe via e-mail
print this post follow me on twitter


About The Author

Suprotim Agarwal, ASP.NET Architecture MVP works as an Architect Consultant and provides consultancy on how to design and develop Web applications.

Suprotim is also the founder and primary contributor to DevCurry, DotNetCurry and SQLServerCurry. He has also written an EBook 51 Recipes using jQuery with ASP.NET Controls.

Follow him on twitter @suprotimagarwal

comments

2 Responses to "Remove Links and Display Text using jQuery"
  1. Anonymous said...
    March 9, 2011 12:26 AM

    sounds good

  2. Anonymous said...
    June 7, 2011 9:00 AM

    Excelente tips, me ayudo mucho

    v_omar

 

Copyright © 2009-2012 All Rights Reserved for DevCurry.com by Suprotim Agarwal | Terms and Conditions