Jquery 一般使用 - lextel/evolution GitHub Wiki

  1. 判断某个dom是否在当前页面

如<div id='test'></div>

if($('#text').length > 0) {
// 存在

}

  1. 多选框判断是否选中
如 <label><input type="checkbox" name="ids[]" value="1">我是第一个</label>
<label><input type="checkbox" name="ids[]" value="2">我是第二个</label>
if($('input[name="ids[]"]:checked').length > 0) {
// 有选中的checkbox

}

  1. jquery 1.8 后attr有所改变

如:多选框全选反选功能 已经更换为:prop

$('input[action="selectAll"]').click(function () {
if (this.checked) {
$('input[name="ids[]"]').prop('checked', true);
} else {
$('input[name="ids[]"]').prop('checked', false);

}

});

IE8下文件上传需要注意:

获取文件对象 browser方法在1.9后放弃使用,建议使用$.support.leadingWhitespace

if ($.browser.msie) {

}

⚠️ **GitHub.com Fallback** ⚠️