user2806026
user2806026

Reputation: 817

.click() doesn't work with (document).ready()

My jQuery('a[data-filter=".hottop"]').click(); doesn't work together with my document.ready function. The click works fine when fired from console, and document.ready fires everything else just fine. It just doesn't trigger the click.

Can someone figure out why?

Live Page. Site isn't public yet, so please identify with stackof//123O

Upvotes: 0

Views: 615

Answers (2)

Francis Saul
Francis Saul

Reputation: 750

For some reason I can't explain why it is happening, I used to experience the same thing and I'm creating DOM elements dynamically. Could you try this

            $("body").on('click', 'yourClass/ID-Element', function () {
       //your codes

});

Upvotes: 1

user2806026
user2806026

Reputation: 817

Using the following function made everything work:

$(window).load(function()

Thanks!

Upvotes: 0

Related Questions