All jQuery Interview Question

How to Check element exists or not in jQuery

Have you ever thought that what will happen if you try to access an element using jQuery which does not exist in your DOM? For example, I am accessing "dvText" element in below code and that element does not exists in my DOM. var obj = $("#dvText"); alert(obj.text()); What will happen? There could be 2 […]
Read the rest of this entry »

jQuery – bind() vs live() vs delegate() methods

I had already posted about jQuery bind(), jQuery live() and  jQuery delegate() functions. All the three jQuery functions are used to attach events to selectors or elements. But just think why there are 3 different functions for same purpose? There can't be. right? So in this post, I will explain you how these functions are […]
Read the rest of this entry »

width() vs css(‘width’) and height() vs css(‘height’)

jQuery provides two ways to set width and height of any element. You can set using css or you can use jQuery provided methods. If you want to set width to 100px then $('#dvText1').css('width','100px'); $('#dvText2').width(100); Then what is the difference? The difference lies in datatype. As its clear in code that with css method you […]
Read the rest of this entry »

Difference between $(this) and ‘this’ in jQuery

Before writing this post, I was also confused about '$(this)' and 'this' in jQuery. I did some R&D and found out the difference between both of them. Let's first see how do we use them. $(document).ready(function(){ $('#spnValue').mouseover(function(){ alert($(this).text()); }); }); $(document).ready(function(){ $('#spnValue').mouseover(function(){ alert(this.innerText); }); }); Got any idea about the difference? this and $(this) refers […]
Read the rest of this entry »

jQuery Tip – How to check if element is empty

In this post, I will show you a simple tip to check or verify that the element that you are accessing in jQuery is empty or not. jQuery provides a method to get and set html of any control. Check these articles for more details. Get HTML of any control using jQuery Set HTML of […]
Read the rest of this entry »

What is jQuery.noConflict()

What is jQuery.noConflict()? Well, jQuery is popular because there are plenty of useful, simple and easy to use plugins. But while using jQuery plugins, sometimes we include other libraries like prototype, mootools, YUI etc. The problem comes when one or more other libraries are used with jQuery as they also use $() as their global […]
Read the rest of this entry »

Responsive Menu
Add more content here...