Solved

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

Posted on 2013-12-10
2
651 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

825 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