Archive for August, 2010

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 »

Detect Browsers using jQuery

jQuery provides a property to detect the browser. It works well for IE, mozilla, Safari and opera browser but it doesn't work for Google Chrome. Below jQuery code gives you an idea about $.browser property. $(document).ready(function() { if ($.browser.mozilla && $.browser.version >= "2.0" ){ alert('Mozilla above 1.9'); } if( $.browser.safari ){ alert('Safari'); } if( $.browser.opera){ […]
Read the rest of this entry »

Wow!!! We have jQuery Mobile now

Wow!!!! Very soon we will be having jQuery mobile framework which will work with all the major mobile browsers. jQuery team has officially announced it. As per the jQuery team jQuery mobile is "Delivering top-of-the-line JavaScript and a unified User Interface across the most-used smartphone web browsers." Till now no other framework has targeted so […]
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 »

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 »

How to use hover method in jQuery

In my earlier post, I have posted about how to provide highlight effect on mouseover and mouseout using jQuery events. Today, I found another solution which is easy and compact. jQuery provide hover() event which works for both the events. It works for mouseover and it also works for mouseout. Below jQuery code uses the […]
Read the rest of this entry »