K
K
Kusmich2015-11-09 22:19:03
JavaScript
Kusmich, 2015-11-09 22:19:03

How to load text into a block on a timer?

There is an object from which I load data and stuff them into tags. Everything would be fine, but the place in the widget is not rubber (How to change the values ​​in the tag over time? For example, there are three h1 tags, the script from the object loads some text, it takes 2 minutes and it loads the next text from the object and deletes the old one. In case If the text is over, it goes in a circle.. I tried to implement it using a recursive function, but I haven't managed to set up a shift yet... Maybe someone has already designed this

?

var json_date = {
   "dills": {
     "1": {
       "name": "boock_1",
       "time": "15:00",
     },
     "2": {
       "name": "book_2",
       "time": "15:00",
     },
     "3": {
       "name": "book_3",
       "time": "09:00",

     },
     "4": {
       "name": "book_4",
       "time": "05:00",

     }
   }
 }


var ix = 0;

$.each(json_date['dills'], function(key, val) {
  
 

$('li > h1').eq(ix++).text("").text(val.name);
console.log(ix);
});


Here is the whole fiddle code: https://jsfiddle.net/sxzk9ooa/6/

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2015-11-09
@Kusmich

setInterval()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question