How does jquery get random colors?
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)