Home  >  Article  >  Web Front-end  >  How to get the day of the week with jquery

How to get the day of the week with jquery

藏色散人
藏色散人Original
2020-11-26 11:31:122083browse

Jquery method to get the day of the week: first create a new html file and create an array week; then use "new Date()" to get today's time and save it in the mydd variable; then use the getDay method to get The number of today’s week; finally, just take out the Chinese name of the week from the array week.

How to get the day of the week with jquery

Recommended: "jquery tutorial"

The operating environment of this tutorial: Windows 7 system, jquery version 1.10.0, applicable For all brands of computers.

How to get the day of the week with jquery:

Create a new html file named test.html to explain how jquery gets the day of the week today.

How to get the day of the week with jquery

In the test.html file, create an array week, and store the Chinese name of the week in the array.

How to get the day of the week with jquery

In the test.html file, use new Date() to get today’s time and save it in the mydd variable.

How to get the day of the week with jquery

In the test.html file, use the getDay() method to obtain today’s week number through today’s time object. The number 0 is Sunday and the numbers 1 to 6 are Monday to Saturday.

How to get the day of the week with jquery

In the test.html file, use the number of the week in the previous step to get the Chinese name of the week from the array week and use alert() method output.

How to get the day of the week with jquery

Open the test.html file in the browser to view the results.

How to get the day of the week with jquery

The above is the detailed content of How to get the day of the week with jquery. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn