how to check whether element is visible on screen


Sometime we need to load some content when that element is visible on browser. So first we need to find whether that element is visible on the browser or not.
Below is the demo example :
Javascript function :
function isVisible(elem)
{
var TopView = $(window).scrollTop();
var BotView…

Advertisements

How to check wheather checkbox is checked?


To check whether a checkbox is checked with a particular class name : if($(“<class_name>:checkbox:checked”).length == “1”){ alert(‘Its checked’); } To check whether a checkbox is checked : if($(“input:checkbox:checked”).length == “1”){ alert(‘Its checked’); }

How to create a fade-in fade-out hint box for an element


Here is the example of fade-in fade-out hint box for an element.   <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt; <html xmlns=”http://www.w3.org/1999/xhtml”&gt; <head> <script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js”&gt; </script> <style> .my_cust_css{border:1px solid #333; display:none; background:#09F; border-radius:5px; padding:5px; width:180px;} </style> </head> <body> <a href=”#” class=”jqury_hint” id=”first” rev=”hello this is test message.”>chandan</a> <br /><br /><br /><br /> <a href=”#”…

Set attributes of the element


The .attr(attributeName, value) method sets the attribute value for element. Hello World var link = $(‘a’).attr(‘title’,’Hello World’); With the above example you will get the href of the anchor tag.

Get the value of an attribute


The .attr() method gets the attribute value for only the first element in the matched set. Hello World ​var link = $(‘a’).attr(‘href’);​​​​​​​​ alert(link); With the above example you will get the href of the anchor tag.