jQuery笔记之html()和text()的区别: html()方法:相当于js中的innerHTML 设置或读取该节点中的html代码 如 var content = $("a").html(); text()方法:相当于中的innerText 设置或读取该节点中的纯文本
form表单精确选中: $("input[type='button']") 两种方案判断单选框(radio)是否被选中: 方法一: var sex_flag = false; for(var i=0; i$(":radio").length; i++){ if($(":radio")[i].checked == true){ sex_flag = true; } } if(s
随滚动条下移,不断加载新内容方法: $(window).scroll(function(){ if($(document).height() - $(window).height() - $(document).scrolltop() = 200;){ //当滚动条距离底部200px时,执行下面的代码 $("body").append("div
find()方法: 作用:在已经选择的选择器结果中做条件查找: 如:$("#div1").find("a").find("h5").css("color","red")//给id为div1的容器里的a容器里的h5变为红色
jQuery的链式操作可以有下面几种写法: 写法一: $("ul li").css("float","left");$("ul li").css("list-style","none");$("ul li").css("margin","0px"); 写法二: $("ul li").css("float","left").css("list-style","none").css("mar
定义:设置或返回匹配元素相对滚动条顶部的偏移。 语法:$(selector).scrollTop(offset) 参数:offset 描述:可选,规定相对于滚动条顶部的偏移,以像素计算。 读取:$("选择器").scrollTop()//获
1.用css的定位fixed来实现按钮不随滚动条滚动而变动位置,自始至终在右下角。 2.完成鼠标附上去按钮变化:addClass和removeClass 3.点击之后滑动到顶部: 动画animate({},1500); 4.判断什么时候
$(document).width() $('body').width() ? $(document).width() : $('body').width(); $(document).height() $('body').height() ? $(document).height() : $('body').height(); alert($(window).height()); //浏览器时下窗口可视区域高度 alert(
var from = 'abcdefg'; var to = from.substr(1,3); //表示从1位开始截取后面的3个字符,"bcd"。位置从零开始 to = from.substring(1,3); //表示从1位开始截取到3位,"bc"。位置从零开始
*.location.href 用法: top.location.href=”网站网址” 在顶层页面打开url(跳出框架) self.location.href=”网站网址” 仅在本页面打开url地址 parent.location.href=”网站网址” 在父窗口打开Url地址