Home > front end >  Color switching questions
Color switching questions

Time:04-02

The HTML code is as follows, original intention is to change & lt; each click on the button h1> Color, but found that run up, could you help to look at, also want to seek advice if you want to can button has been pressed (namely after color to last a for loop, continue to click on the button switch will start from the first color) also need to how to change the code, thank you

<body>




<script>
Var colors=[' red ', 'blue', 'yellow'].//here only put three colors, assuming that the actual colors with thousands of colors in

Var len=colors. Length;
The function the text () {
For (var I=0, I & lt; Len. I++) {
Document. The getElementById (' id1). Style, color=colors [I];
}
}
</script>

CodePudding user response:

Click on the change, you directly according to the colors good index to specify a color ah, traverse is to do?

CodePudding user response:

reference 1/f, bubble fish _ response:
click on the change, you can directly according to the colors good index to specify a color ah, traverse is to do?


Trouble if according to the colors under consulting index to specify a color need how to write

CodePudding user response:

. You first look at the array

CodePudding user response:

Looking for a like novice tutorial site, at least see all the stuff from the javascript related + the exercises that are corresponding to the once

  • Related