Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does jquery get random colors?

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how to get random color from jquery". In daily operation, I believe many people have doubts about how to get random color from jquery. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubt about "how to get random color by jquery". Next, please follow the editor to study!

The specific steps are as follows:

1. First, create a new html project and introduce jquery into the project

two。 After introducing jquery, create a p tag in the project and set the text and id properties for testing

Test text

After the 3.p tag is created, add a button button and bind the onclick click event to click to get a random color

4. Finally, after the button is added, the tag object is obtained through id in the click event, and the random color value is generated by using the random () function and assigned to the color attribute.

Function set () {

$("# text"). Css ("color", "#" + ('00000 text + (Math.random () * 0x1000000)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report