What is the “hasClass” function with plain JavaScript?

You can check whether element.className matches /\bthatClass\b/.\b matches a word break. Or, you can use jQuery’s own implementation: To answer your more general question, you can look at jQuery’s source code on github or at the source for hasClass specifically in this source viewer.

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

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?

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)