Solved

JQuery - loop through a string and select a character in a word

Posted on 2013-12-10
2
678 Views
Last Modified: 2013-12-10
I need to loop through every character in a string in Jquery. Is this right?

Any ideas
var var_string;
var_string = "excellent";

for(var char in var_string)
{

alert(char);


}
0
Comment
Question by:GlobaLevel
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 39710549
use charAt : http://jsfiddle.net/8ernN/

var var_string;
var_string = "excellent";

for(var i=0;i<var_string.length;i++)
{

alert( var_string.charAt(i) );


}

Open in new window

0
 
LVL 10

Author Closing Comment

by:GlobaLevel
ID: 39710561
excellent
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question