Check if an image is loaded (no errors) with jQuery

I’m using JavaScript with the jQuery library to manipulate image thumbnails contained in a unordered list. When the image is loaded it does one thing, when an error occurs it does something else. I’m using jQuery load() and error() methods as events. After these events I check the image DOM element for the .complete to … Read more

jQuery lose focus event

I’m trying to show up a container if a input field gets the focus and – that’s the actual problem – hide the container if focus is lost. Is there an opposite event for jQuery’s focus? Some example code: <input type=”text” value=”” name=”filter” id=”filter”/> <div id=”options”>some cool options</div> <script type=”text/javascript”> $(‘#options’).hide(); $(‘#filter’).focus(function() { $(‘#options’).appear(); }); … Read more

JavaScript click handler not working as expected inside a for loop [duplicate]

This question already has answers here: How do JavaScript closures work? (86 answers) Closed 8 years ago. I’m trying to learn JS and got an issue. I tried many things and googled but all in vain. Following piece of code doesn’t work as expected. I should get value of i on click but it always … Read more

Getting value of select (dropdown) before change

The thing I want to achieve is whenever the <select> dropdown is changed I want the value of the dropdown before change. I am using 1.3.2 version of jQuery and using on change event but the value I am getting over there is after change. <select name=”test”> <option value=”stack”>Stack</option> <option value=”overflow”>Overflow</option> <option value=”my”>My</option> <option value=”question”>Question</option> … Read more