All In One Script
MENU

How to redirect to another webpage in JavaScript/jQuery?

by 4:46:00 AM
undefined
How to redirect to another webpage in JavaScript/jQuery? How can I redirect the user from one page to another using javascript or jQuery? Answer: One does not simply redirect using jQuery jQuery is not necessary, and window.location.replace(...) will best simulate an HTTP redirect. window.location.replace(...) is better than using window.location.href, because replace()does not keep the originating page in the session history, meaning the user won't get stuck in a never-ending back-button fiasco.       If you want to simulate someone clicking on a link, use location.href      

Modify the URL without reloading the page

by 3:18:00 AM
undefined
Modify the URL without reloading the page Is there any way I can modify the URL of the current page without reloading the page? I would like to access the portion before the # hash if possible. I only need to change the portion after the domain, so its not like I'm violating cross-domain policies. window.location.href = "www.mysite.com/page2.php"; // sadly this reloads Answer: This can now be done in Chrome, Safari, FF4+, and IE10pp4+! See this question's answer for more info: Updating address bar with new URL without

Change an element's class with JavaScript

by 3:15:00 AM
undefined
Change an element's class with JavaScript How can I change a class of an HTML element in response to an onClick event using JavaScript? Answer: Adding and Removing Classes, with simple cross-browser JavaScript The standard JavaScript way to select an element is using document.getElementById("Id"), which is what the following examples use - you can of course obtain elements in other ways, and in the right situation may simply use this instead - however, going into detail on this is beyond the scope of the answer. To change all

Setting “checked” for a checkbox with jQuery?

by 12:42:00 AM
undefined
Setting “checked” for a checkbox with jQuery? I'd like to do something like this to tick a checkbox using jQuery: $(".myCheckBox").checked(true); or $(".myCheckBox").selected(true); Does such a thing exist? Answer: jQuery 1.6+ Use the new .prop() method: $('.myCheckbox').prop('checked', true); $('.myCheckbox').prop('checked', false); jQuery 1.5.x and below The .prop() method is not available, so you need to use .attr(). $('.myCheckbox').attr('checked', true); $('.myCheckbox').attr('checked', false); Note that this is the approach used by jQuery's unit tests prior to version 1.6 and is preferable to using $('.myCheckbox').removeAttr('checked'); since the latter will, if the box was initially checked, change the

Instagram