Labels:
jQuery,
jQuery Functions,
jQuery Methods,
Methods
jQuery provides a method "split()", which splits the text. We can use any delimiter to split the text. Let me explain you with an example. First declare a label and assign some text to it. We will split the text using space as delimiter.
Feel free to contact me for any help related to jQuery. I will gladly help you.
<asp:Label ID="lblMessage" runat="server" Text="jQuery By Example Rocks!!" />See below jQuery code, which makes use of split function and split the string with space.
<script type="text/javascript">
$(document).ready(function(){
var element = $("#lblMessage").text().split(" ");
alert(element);
});
</script>
Thing to note here is the variable "element" declared in jQuery code becomes an array and you can easily iterate through it. If you say alert(element[0]) then it will alert jQuery.
Don't forget to read
Mostly used and essential jQuery code snippets.
Mostly asked jQuery interview questions list.
Read my other helpful posts:
Mostly used and essential jQuery code snippets.
Mostly asked jQuery interview questions list.
Feel free to contact me for any help related to jQuery. I will gladly help you.