Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jQuery で5秒後とかに addClass したいとき #61

Open
shikakun opened this issue Feb 21, 2014 · 0 comments

Comments

Projects
None yet
1 participant
@shikakun
Copy link
Owner

commented Feb 21, 2014

$('#selector').delay(5000).addClass('hogemoge');

とか書いても、delay はアニメーションにしか効かないので、ページを読み込んだタイミングで addClass してしまう。
以下のように書けば5秒後に addClass できる。

方法1

$('#selector').delay(5000).queue(function(next) {
    $(this).addClass('hogemoge');
    next();
});

方法2

$('#selector').delay(5000).queue(function() {
    $(this).addClass('hogemoge').dequeue();
});

参考

@shikakun shikakun added the jQuery label Feb 21, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.