jQuery delay not working

.delay() is used for items that are part of a queue, like animations. A simple addClass is not queued. You could use setTimeout. As an alternative, you could add the non-queued item to the queue using .queue(), though I think a setTimeout would be better.

Show div #id on click with jQuery

The problem you’re having is that the event-handlers are being bound before the elements are present in the DOM, if you wrap the jQuery inside of a $(document).ready() then it should work perfectly well: An alternative is to place the <script></script> at the foot of the page, so it’s encountered after the DOM has been loaded and ready. To … Read more

how to define variable in jquery

jQuery is just a javascript library that makes some extra stuff available when writing javascript – so there is no reason to use jQuery for declaring variables. Use “regular” javascript: EDIT: As Canavar points out in his example, it is also possible to use jQuery to get the form value: given that the text box … Read more

Using OR operator in a jQuery if statement

Think about what means. || means “or.” The negation of this is (by DeMorgan’s Laws): In other words, the only way that this could be false is if a state equals 10, 15, and 19 (and the rest of the numbers in your or statement) at the same time, which is impossible. Thus, this statement will always be true. State 15 … Read more

How to get mouse position in jQuery without mouse-events?

I don’t believe there’s a way to query the mouse position, but you can use a mousemove handler that just stores the information away, so you can query the stored information. But almost all code, other than setTimeout code and such, runs in response to an event, and most events provide the mouse position. So your code that needs to know where … Read more