How do I set/unset a cookie with jQuery?

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 github for details. Before April 2019 (old) See the plugin: You can then do: To delete: Additionally, to set a timeout … Read more

React Error: Target Container is not a DOM Element

I figured it out! After reading this blog post I realized that the placement of this line: was wrong. That line needs to be the last line in the <body> section, right before the </body> tag. Moving the line down solves the problem. My explanation for this is that react was looking for the id in between the <head> tags, instead of in … Read more

Find an element in DOM based on an attribute value

Update: In the past few years the landscape has changed drastically. You can now reliably use querySelector and querySelectorAll, see Wojtek’s answer for how to do this. There’s no need for a jQuery dependency now. If you’re using jQuery, great…if you’re not, you need not rely it on just for selecting elements by attributes anymore. There’s not a very short way … Read more

querySelector vs. getElementById

I have heard that querySelector and querySelectorAll are new methods to select DOM elements. How do they compare to the older methods, getElementById and getElementsByClassName in terms of performance and browser support? How does the performance compare to using jQuery’s query selector? Is there a best practice recommendation for which method to use?