当前位置: 代码迷 >> Web前端 >> jquery惯用代码
  详细解决方案

jquery惯用代码

热度:31   发布时间:2012-09-10 22:20:12.0
jquery常用代码

1.ready方法

//可以用来测验 jquery是否加载成功
$(document).ready(
function()
{
	alert(11);
}
)

//简版
$(function(){
   alert(11);
})

?

2.遍历

$("input:checked").each(function(){
           $(this).attr("id");
})


$("input[readonly='true']:not([onclick])").each(function(){
           $(this).css("color","#CECED1");
})

?

3.搜索内容高亮显示

var val = "所搜的内容";
$("#contentDiv font").each(function(){
    $(this).html($(this).text().replace(val,"<font color='red'>"+val+"</font>"));
})

?

待完善。。。

  相关解决方案