Using JS split method to realize _javascript technique of color text background effect example

Source: Internet
Author: User

Let's take a look at the implementation chart.

Effect implementation steps:

1, to obtain the elements to be used;

2, declare an array variable ( arrColor ) to store the color value;

3, to the button to add click events;

4. Get the value of the text box value , and use the split method to convert the string value of the text box into the array ( arr ) storage;

5, loop out the value of the stored array ( arr ) and add on the span label;

6, set span the background color of the label: from the Array ( arrColor ) loop value;

7. Add the set content to the div middle;

Effect complete code:

 <!doctype html>  
 

Summarize

Using JS Split method to realize the example of color text background to this end, interested friends can do their own hands-on look, I hope that the study work can help.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.