This trick will be useful when you want to check if the element with specific ID is available in DOM or not. This tricks is preferable to use on domready event of the page. If you are not sure what does domready means then I suggest you to have a look at this article related to domready.
Its prety simple to check the existence of element using MooTools. All you need is just an ID of the element. Have a look at below code block for the same:
In jQuery, if you try the MooTools way then it will always show that element is exists. Try below code and see:
The reason behind this is as follow:
Because in jQurey $(‘#ID’) will always return object, it will return blank object if element is not exists in DOM. So to really check the existence you need to use below code:
Avinash Zala is leading various projects which deals with the various technology involved with the web. A combination of perfect technical and management skills. Avinash would like to chat with you and convert your imagination into the working system. You can get in touch with him on Facebook and Twitter.
View all posts by: Avinash