Subscribe to Subscribers
Talk to Webmaster Tony John

Online Members

More...

Resources » Code Snippets » jQuery

How to use Replace in Jquery?


Posted Date:     Category: jQuery    
Author: Member Level: Gold    Points: 20


In this article, I'm going to explain how to replace a word in a string using Jquery.



 


In this article, I'm going to explain how to replace a word in a string using Jquery. To Demonstrate that, Let us read text from a div control , replace it with out text and then assign the replaced text to same control, as shown in the below example.This code will replace first occurrence of the string.


<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script language="javascript" src="jquery-1.2.6.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function()
{
$("#Button1").click(function()
{
var txt = $('#pid').text().replace('','');
alert(txt);
});



});
</script>

</head>
<body>
<form id="form1" runat="server">
<div>
<p id="pid">15 <span></span></p>
<asp:Button ID="Button1" runat="server" Text="Button" />
</form>
</body>
</html>





Did you like this resource? Share it with your friends and show your love!


Responses to "How to use Replace in Jquery?"

No responses found. Be the first to respond...

Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Next Resource: Jqury Syntax
    Previous Resource: How to use selectors in JQuery
    Return to Resources
    Post New Resource
    Category: jQuery


    Post resources and earn money!
     
    More Resources
    Popular Tags   Tag posting guidelines   Search Tags  
    How to use Replece in Jquery?  .  
    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.