Home > Web Front-end > JS Tutorial > Assign values ​​to multiple spans through jquery after the page is loaded_jquery

Assign values ​​to multiple spans through jquery after the page is loaded_jquery

WBOY
Release: 2016-05-16 16:47:33
Original
1667 people have browsed it

Since I want to display the current time in several places after the page is loaded, I need to assign values ​​to multiple spans.

The span code is written as follows:

Copy the code The code is as follows:

(multiple spans)

jQuery writing:
Copy code The code is as follows:

<script> <br>$(document).ready(function() { <br>var currentDate = new Date().toLocaleDateString (); <br>$("span[name='currentDate']").each(function() { <br>$(this).text(currentDate); <br>}); <br>}) ; <br></script>
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template