Home  >  Article  >  Web Front-end  >  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
WBOYOriginal
2016-05-16 16:47:331649browse

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>
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