js为修改input属性

</pre><p>1.将input标签设置为不可编辑:</p><p></p><pre name="code" class="html">(1)设置
document.getElementById("select类型").disabled="disabled";
document.getElementById("input myDate97").disabled="disabled";
document.getElementById("普通的input文本框").disabled="disabled";
(2)去除
document.getElementById("input").disabled=false;

2.修改背景颜色为浅灰色:

document.getElementById("travlSelect").style.background="#eee"; 

3.显示或隐藏:

显示:
1.document.getElementById("li_1_1").style.display = "";
2.document.getElementById("li_1_1").style.display = "block";
隐藏:
document.getElementById("li_1_1").style.display = "none";


4.js改变checkbox的选中状态

document.getElementById("id").checked = true;
document.getElementById("id").checked = false;

5.select标签根据后台传值显示某一个标签

<script type="text/javascript">
function test() {
var sel = document.getElementById("memberquestion");
for (var i = 0; i < sel.length; i++) {
if (sel[i].value == "您母亲的名字") {
//后台传过来的数据
sel[i].selected = true;
}
}
}

</script>
<span style="color: rgb(69, 69, 69); font-family: arial, 宋体, sans-serif, tahoma, 'Microsoft YaHei'; font-size: 14px; line-height: 24px;">name="mike"</span><br style="color: rgb(69, 69, 69); font-family: arial, 宋体, sans-serif, tahoma, 'Microsoft YaHei'; font-size: 14px; line-height: 24px;" /><span style="color: rgb(69, 69, 69); font-family: arial, 宋体, sans-serif, tahoma, 'Microsoft YaHei'; font-size: 14px; line-height: 24px;">for(var i=0;i<memberqueston.options.length;i++){</span><br style="color: rgb(69, 69, 69); font-family: arial, 宋体, sans-serif, tahoma, 'Microsoft YaHei'; font-size: 14px; line-height: 24px;" /><span style="color: rgb(69, 69, 69); font-family: arial, 宋体, sans-serif, tahoma, 'Microsoft YaHei'; font-size: 14px; line-height: 24px;">if(name==memberquestion.options[i].value){</span><br style="color: rgb(69, 69, 69); font-family: arial, 宋体, sans-serif, tahoma, 'Microsoft YaHei'; font-size: 14px; line-height: 24px;" /><span style="color: rgb(69, 69, 69); font-family: arial, 宋体, sans-serif, tahoma, 'Microsoft YaHei'; font-size: 14px; line-height: 24px;">memberquestion.options[i].selected = true;</span><br style="color: rgb(69, 69, 69); font-family: arial, 宋体, sans-serif, tahoma, 'Microsoft YaHei'; font-size: 14px; line-height: 24px;" /><span style="color: rgb(69, 69, 69); font-family: arial, 宋体, sans-serif, tahoma, 'Microsoft YaHei'; font-size: 14px; line-height: 24px;">return;</span><br style="color: rgb(69, 69, 69); font-family: arial, 宋体, sans-serif, tahoma, 'Microsoft YaHei'; font-size: 14px; line-height: 24px;" /><span style="color: rgb(69, 69, 69); font-family: arial, 宋体, sans-serif, tahoma, 'Microsoft YaHei'; font-size: 14px; line-height: 24px;">}</span><br style="color: rgb(69, 69, 69); font-family: arial, 宋体, sans-serif, tahoma, 'Microsoft YaHei'; font-size: 14px; line-height: 24px;" /><span style="color: rgb(69, 69, 69); font-family: arial, 宋体, sans-serif, tahoma, 'Microsoft YaHei'; font-size: 14px; line-height: 24px;">}</span>



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值