js为修改input属性

来源:互联网 发布:m20火箭筒数据 编辑:程序博客网 时间:2024/06/05 03:19
</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>



0 0
原创粉丝点击