$('.pre >child'):pre下的所有直接子节点
$('.pre + div'):pre后面的第一个div兄弟节点
$('.pre p'):pre下的所有层P
$('.pre ~ div'):选择pre后面的所有兄弟节点
$('.pre + div'):pre后面的第一个div兄弟节点
$('.pre p'):pre下的所有层P
$('.pre ~ div'):选择pre后面的所有兄弟节点
2016-12-21
举的例子和data-没关系,data-例子可以这样:
body中:<div class="right1" data-abc="123"></div>
<script>
alert($('.right1').data('abc'));//读
$('.right1').data('abc','345')//写
alert($('.right1').data('abc'));//读
</script>
body中:<div class="right1" data-abc="123"></div>
<script>
alert($('.right1').data('abc'));//读
$('.right1').data('abc','345')//写
alert($('.right1').data('abc'));//读
</script>
2016-12-21
解释得还是比较清楚的,仔细看故意写的代码,contains就是指明需要的元素中的值,可以说是实际的内容,而has就是指包含内容的标签。
2016-12-21
//js方法
function addClass(obj,add,find){
var old=obj.className;
if(find!=''){
if(old.indexOf(find)==-1){
return;
}
}
var newClass=old+' '+add;
obj.className=newClass;
}
function addClass(obj,add,find){
var old=obj.className;
if(find!=''){
if(old.indexOf(find)==-1){
return;
}
}
var newClass=old+' '+add;
obj.className=newClass;
}
2016-12-21
firefox45以后就支持innerText了,测试在firefox 50.1.0下正常。
2016-12-21
感到吃力的同学可能是css不太熟练和熟悉。如果css比较熟悉了,至少在目前阶段不会觉得怎么难。这个课表述上有些地方不是很清晰,但是对于css比较熟的人应该不难理解。
2016-12-21
jQuery.data( element, key, value ) //静态接口,存数据
jQuery.data( element, key ) //静态接口,取数据
.data( key, value ) //实例接口,存数据
.data( key ) //实例接口,取数据
jQuery.data( element, key ) //静态接口,取数据
.data( key, value ) //实例接口,存数据
.data( key ) //实例接口,取数据
2016-12-20
function addClassName(id,name){
document.getElementById(id).className='name';
}
addClassName(id,name);
document.getElementById(id).className='name';
}
addClassName(id,name);
2016-12-20
通过把$()方法传入当前的元素对象的引用this,把这个this加工成jQuery对象
$this= $(this)
$this= $(this)
2016-12-19
1.查找所有input所有可用的(未被禁用的元素)input元素。$('input:enabled')
2.查找所有input所有不可用的(被禁用的元素)input元素。$('input:disabled')
3.查找所有input所有勾选的元素(单选框,复选框) 。$('input:checked')
4.查找所有option元素中,有selected属性被选中的选项。$('option:selected') 用于下拉菜单
2.查找所有input所有不可用的(被禁用的元素)input元素。$('input:disabled')
3.查找所有input所有勾选的元素(单选框,复选框) 。$('input:checked')
4.查找所有option元素中,有selected属性被选中的选项。$('option:selected') 用于下拉菜单
2016-12-19