Split text using JQuery

Virendradugar
Posted by Virendradugar under jQuery category on | Views : 67610
Below code will split text of any element using JQuery. You can download the Jquery from http://docs.jquery.com/Downloading_jQuery.

jQuery provides a method "split()", which splits the text. We can use any delimiter to split the text. I have used space to split.
<script type="text/javascript" src="Script/jquery-1.5.1.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var element = $("#lblMessage").text().split(' ');
alert(element);
});
</script>

Below is the label with ID "lblMessage", which we have used in jQuery to split the text.
<asp:Label ID="lblMessage" runat="server" Text="Dotnetfunda rocks"></asp:Label>

Enjoy..

For detailed walk through of split function visit http://bit.ly/troMk4

Visit my blog
http://jquerybyexample.blogspot.com/

Comments or Responses

Posted by: Jayeshl on: 4/6/2011 Level:Starter | Status: [Member] | Points: 10
Thanks, it really helped.

I found another article which explains about jQuery split function in detail. Visit below link ..

http://jquerybyexample.blogspot.com/2011/03/jquery-split-revisited.html

Thanks,
Jayesh

Posted by: Phagu007 on: 7/19/2013 Level:Starter | Status: [Member] | Points: 10
Dear Virendra
It is a useful code for Split text using JQuery

Login to post response