jquery
How to manage a redirect request after a jQuery Ajax call
The solution that was eventually implemented was to use a wrapper for the callback function of the Ajax call and in this wrapper check for the existence of a specific element on the returned HTML chunk. If the element was found then the wrapper executed a redirection. If not, the wrapper forwarded the call to … Read more
Bootstrap collapse isn’t working; hamburger menu not showing up
The markup of your navbar is not correct. The markup should be as follows: In the ul element, place the menu items. That should do the trick. See also the documentation
Escaping HTML strings with jQuery
Since you’re using jQuery, you can just set the element’s text property:
How to disable scrolling temporarily?
The scroll event cannot be canceled. But you can do it by canceling these interaction events:Mouse & Touch scroll and Buttons associated with scrolling. [Working demo] UPDATE: fixed Chrome desktop and modern mobile browsers with passive listeners
Convert array to JSON
Script for backward-compatibility: https://github.com/douglascrockford/JSON-js/blob/master/json2.js And call: Note: The JSON object is now part of most modern web browsers (IE 8 & above). See caniuse for full listing. Credit goes to: @Spudley for his comment below
Reload an iframe with jQuery
If the iframe was not on a different domain, you could do something like this: But since the iframe is on a different domain, you will be denied access to the iframe’s contentDocument property by the same-origin policy. But you can hackishly force the cross-domain iframe to reload if your code is running on the iframe’s parent page, … Read more
Get class list for element with jQuery
You can use document.getElementById(‘divId’).className.split(/\s+/); to get you an array of class names. Then you can iterate and find the one you want. jQuery does not really help you here…
Changing the image source using jQuery
You can use jQuery’s attr() function. For example, if your img tag has an id attribute of ‘my_image’, you would do this: Then you can change the src of your image with jQuery like this: To attach this to a click event, you could write: To rotate the image, you could do this: