{"id":795,"date":"2024-10-09T21:58:37","date_gmt":"2024-10-09T21:58:37","guid":{"rendered":"https:\/\/javigomez.org\/?p=795"},"modified":"2025-09-29T20:32:51","modified_gmt":"2025-09-29T20:32:51","slug":"setinterval-y-settimeout","status":"publish","type":"post","link":"https:\/\/javigomez.org\/index.php\/2024\/10\/09\/setinterval-y-settimeout\/","title":{"rendered":"setInterval() y setTimeout()"},"content":{"rendered":"\n<p>Se ilustra como utilizar estas dos funciones para retardar la ejecuci\u00f3n de funciones en Javascript.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html>\n&lt;html lang=\"en\">\n&lt;head>\n    &lt;meta charset=\"UTF-8\">\n    &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    &lt;title>Tiempos&lt;\/title>\n&lt;\/head>\n&lt;body>\n    &lt;div id=\"info\">&lt;\/div>\n    &lt;div id=\"periodo\">&lt;\/div>\n\n&lt;script>\n    setTimeout(carga,5000)\n    setTimeout(quitar,10000)\n    let intervalo\n    function carga(){\n        document.getElementById(\"info\").innerHTML+=\"5s\"\n        intervalo=setInterval(periodico,2000)\n    }\n    function periodico(){\n        document.getElementById(\"periodo\").innerHTML+=\"2s\"\n    }\n    function quitar(){\n        document.getElementById(\"info\").innerHTML+=\" QUITAR \"\n        clearInterval(intervalo)\n    }\n&lt;\/script>\n&lt;\/body>\n&lt;\/html><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"DWEC U03 setTimeout setInterval\" width=\"1200\" height=\"675\" src=\"https:\/\/www.youtube.com\/embed\/-7osxl6uy68?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Se ilustra como utilizar estas dos funciones para retardar la ejecuci\u00f3n de funciones en Javascript.<\/p>\n","protected":false},"author":1,"featured_media":796,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[83,204,304,306],"class_list":["post-795","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","tag-clearinterval","tag-javascript","tag-setinterval","tag-settimeout"],"_links":{"self":[{"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/posts\/795","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/comments?post=795"}],"version-history":[{"count":1,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/posts\/795\/revisions"}],"predecessor-version":[{"id":842,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/posts\/795\/revisions\/842"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/media\/796"}],"wp:attachment":[{"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/media?parent=795"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/categories?post=795"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/tags?post=795"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}