js&&jq 的常用功能

js的添加属性和移除属性
添加:document.getElementById("down").setAttribute("disabled",true);
移除:document.getElementById("up").removeAttribute('disabled');


jq的添加属性和移除属性
添加:$("#up").attr("disabled",true);
移除:$("#down").removeAttr("disabled");


js控制css的单个和多个样式
document.getElementById("down").style.borderColor="#61AED0";
document.getElementById("down").style.backgroundColor="#61AED0";


jq控制css的单个和多个样式
单个:$("#down").css("backgroundColor","#61AED0");
多个:$("#down").css({background:"#61AED0",borderColor:"#61AED0"});


jq查找元素
$(":input[name='search']").val();
$(obj).parent().find("[name='search']").val();
js&&jq的div的创建
js的div创建

document.createElement("div")
jq的div创建
$('<div></div>').appendTo($("body"));


js的获取焦点和失去焦点
onfocus()和onBlur()
jq的获取焦点和失去焦点
blur()和focus()


js&&jq的获取宽高

js获取当前页面的宽度&&高度
document.documentElement.clientWidth
document.documentElement.clientHeight


jq获取当前页面的宽度&&高度
$(window).width()
$(window).height()


js获取div宽度&&高度
showBox.offsetWidth
showBox.offsetHeight


jq获取div宽度&&高度
$(showBox).outerHeight()
$(showBox).outerWidth()


js获取文档的宽度&&高度
document.body.scrollHeight
 document.body.scrollWidth


jq获取文档的宽度&&高度
$(document).height()
$(document).width()
outerWidth()方法用于获得包括内边界(padding)和边框(border)的元素宽度,如果outerWidth()方法的参数为true则外边界(margin)也会被包括进来
innerWidth()方法用于获得包括内边界(padding)的元素宽度

js的显示和隐藏
msg.style.display="block";
label.style.display="none";


jq的显示和隐藏
$("#msgBox").show();
$(obj).siblings().hide();


js'的编辑内容
document.getElementById("infot").innerHTML=info;
jq的编辑内容
$("#infot").html(info);








评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值