jQuery、JavaScript 操作语句

1、取 input 的 value 值

/**
*jQuery
*/
$("#idName").val(); //根据id
$(".className").val(); //根据class
/**
*JS
*/
document.getElementById("idName").value; //根据id

2、取标签的内容(span、lable、div、select)

/**
*jQuery
*/
$("#idName").html(); //根据id
$(".className").html(); //根据class
/**
*JS
*/
document.getElementById("idName").innerHTML; //根据id
document.getElementById("selectId").value; //根据selectId

3、动态添加和移除disabled属性

/**
*jQuery
*/
$('#uid').attr("disabled",true);  //添加
$('#uid').attr("disabled","disabled") //添加
$('#uid').attr("disabled",false); //移除
$('#uid').removeAttr("disabled"); //移除
/**
*JS
*/
document.getElementById("uid").disabled = "";

4、JS动态显示和隐藏style

document.getElementById("uid").disabled="true"; //禁用(readonly也适用)
document.getElementById("uid").disabled="false";//去除禁用
document.getElementById("uid").style.display="block"; //显示
document.getElementById("uid").style.display="none";//隐藏

5、子界面获取父界面元素内容(span、lable、div)

/**
*jQuery
*/
$(window.parent.document).find("#IdName").text();
/**
*JS
*/
window.parent.document.getElementById("currentPage").innerHTML;

6、子界面获取父界面元素内容(input)

/**
*jQuery
*/
$(window.parent.document).find("#IdName").val();
/**
*JS
*/
window.parent.document.getElementById("currentPage").value ;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值