开发者

Execute html at a certain time

开发者 https://www.devze.com 2023-04-07 11:39 出处:网络
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 loa

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 */);
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号