`
wangminshe89
  • 浏览: 668585 次
文章分类
社区版块
存档分类
最新评论

一些常用的Javascript代码

 
阅读更多

1.焦点:

document.getElementById('id').value.focus();//将光标转到指定的对像区域

2.大小写转换

var str = 'abc';

var str2 = str.toUpperCase(); //ABC

var str3 = str2.toLowerCase() ;//abc

3.取得select 中当前选中的值

<select name=spnmae onChange="alert(this.options[this.selectedIndex].value)">

<option value='001'>001</option>

</select>

4.给指定的options加入相应的值

<select name=s id='s'>

</select>

document.getElementById('s1').options[document.getElementById('s1').length] =new Option(label,value);

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics