Short js snippets working with js jquery and bool valuesinput checkboxes

Get value of checkbox (jquery):

– returns bool true or bool false

Set value of checkbox (jquery):

Second parameter can be true or false.

Convert true or false strings to bool (js):

This is when you know the string will be ‘True’ or ‘FALSE’ for instance. Accepts all case variations of ‘TRUE’ and ‘false’.

javascript – Window.onload vs document.ready ? – Stack Overflow

The ready event occurs after the HTML document has been loaded, while the onload event occurs later, when all content (e.g. images) also has been loaded.

The onload event is a standard event in the DOM, while the ready event is specific to jQuery. The purpose of the ready event is that it should occur as early as possible after the document has loaded, so that code that adds funcionality to the elements in the page doesn’t have to wait for all content to load.

via javascript – Window.onload vs document.ready ? – Stack Overflow.

Chrome Web Store – Visual Event – Show jQuery event listening code

Ever want to know which line of javascript code that is listening to a certain event on an element? Even when working with jQuery?

This tool for Chrome is really sweet!
Chrome Web Store – Visual Event.

However its seems to be native functionality in Chrome already?
See Paul Irish posting here:!topic/google-chrome-developer-tools/NTcIS15uigA

Didnt get it to work in my Chrome browser although. (just like the latest posts in above forum – just shows jquery source code)

Namespacing in Javascript

Why bother with namespaces in javascript?
– You get cleaner and more clear code.

It is more clear what “object” or “task” the function and variables belongs to.
Avoids global function conflicts, my function named Calculate() might conflict with another function inside some js file that has been loaded before my js file.

This is one way of doing it, which I personally prefer:

Another way is this (enclose in sub braces)

Read even more about it here