Skip to content
Advertisement

Tag: jquery

Modifying location.hash without page scrolling

We’ve got a few pages using ajax to load in content and there’s a few occasions where we need to deep link into a page. Instead of having a link to “Users” and telling people to click “settings” it’s helpful to be able to link people to user.aspx#settings To allow people to provide us with correct links to sections (for

Resetting a setTimeout

I have the following: How can I, via a .click function, reset the counter midway through the countdown? Answer You can store a reference to that timeout, and then call clearTimeout on that reference.

How do I set/unset a cookie with jQuery?

How do I set and unset a cookie using jQuery, for example create a cookie named test and set the value to 1? Answer Update April 2019 jQuery isn’t needed for cookie reading/manipulation, so don’t use the original answer below. Go to https://github.com/js-cookie/js-cookie instead, and use the library there that doesn’t depend on jQuery. Basic examples: See the docs on

Disable/enable an input with jQuery?

or Which is the standard way? And, conversely, how do you enable a disabled input? Answer jQuery 1.6+ To change the disabled property you should use the .prop() function. jQuery 1.5 and below The .prop() function doesn’t exist, but .attr() does similar: Set the disabled attribute. To enable again, the proper method is to use .removeAttr() In any version of

JavaScript moving element in the DOM

Let’s say I have three <div> elements on a page. How can I swap positions of the first and third <div>? jQuery is fine. Answer Trivial with jQuery If you want to do it repeatedly, you’ll need to use different selectors since the divs will retain their ids as they are moved around.

Advertisement