`

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>"));
})

 

待完善。。。

0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics