Execute html at a certain time
I am wondering how you execute html on a certain time. I have a small marquee html code tha开发者_StackOverflowt I want to be executed at the time I want, instead of just immediately once the page loads.
Html does not execute, but it renders.
For execution, you need a script or program. For client side, you should use javascipt. Many people use a library that generally improves their code, and makes programming easier. I would recommend jQuery, but there are others.
To do what you are asking in jQuery is trivial, you would use setTimeout
to calculate the time you want it to execute, and then insert or display the html code in the timeout callback function.
The easiest way is to use jquery's marquee plugin to access your marquee
in an easy way.
Then, the HTML
is not executable! You should create a client-side script to achieve your purpose. For example: after adding a reference to jquery.js
and marquee.jquery.js
in your page, try:
HTML:
<marquee id="myMarq">Content here...</marquee>
JS:
$(document).ready(function(){
$("#myMarq").marquee().trigger('stop');
setTimeout(function(){
$("#myMarq").marquee().trigger('start');
},10000 /* or any time-out you want, in milisecond */);
});
精彩评论