一、判断元素是否隐藏
如下html中的div元素是隐藏的:
 代码如下:
script>
 
$('span').html('test div is visible? ' + $('#test').is(':visible'));
  script>
二、判断checkbox是否选中
jquery中可以通过xx.is(':checked')判断checkbox,radiobutton是否是选中状态,如下测试html
 代码如下:
script>
  chkChecked
  chkNoChecked
三、判断是否使用了某个样式
 代码如下:
Peter//注意这里出现了第5个div
//注意这里出现了第6个div
 $("div").one('click', function () { //$("div").one 代表对div元素附加一个事件,
//还能附加多个事件 譬如click或者mouseout时同时执行一些事情
 if ($(this).is(":first-child")) { //is函数发挥作用了,is(":first-child") 代表 
 //判断此div是否第一个出现的div
 $("p").text("It's the first div."); //text和html区别在于是否支持html标记
 // 此时你在里面写个 alert是不会执行的
 } else if ($(this).is(".blue,.red")) { //判断该div是否 具有blue或者red的 class
 $("p").text("这是个蓝色或者红色的div");
 } else if ($(this).is(":contains('Peter')")) { //判断div中是否存在Peter这个词
 $("p").text("It's Peter!");
 } else {
 $("p").html("It's nothing special.");
 }
 $("p").hide().slideDown("slow"); //这是一个动画效果。慢慢展现p的内容
 $(this).css({"border-style": "inset", cursor:"default"});
 });
 script>