amees_me
amees_me

Reputation: 855

setTimeout does not work when put in sequence

I think I made a small typo or something like that, because something clearly doesn't work as it should. I want to change the ID's of two different divs, in a sequence.

setTimeout(function() {$("#t1").attr('id','t1out')}, 4000)});
setTimeout(function() {$("#t2").attr('id','t1')}, 4500)});

Somehow, this manages to mess up the entire javascript, so nothing runs at all.

Any idea what went wrong?

Upvotes: 0

Views: 229

Answers (1)

Arun P Johny
Arun P Johny

Reputation: 388316

There are syntactical problems in the script . There is an extra } at the end of each statements.

setTimeout(function() {
    console.log('1')
    $("#t1").attr('id', 't1out')
}, 4000);
setTimeout(function() {
    console.log('2')
    $("#t2").attr('id', 't1')
}, 4500);

Demo: Fiddle

Upvotes: 2

Related Questions