js小实例(改变宽度)
2008-12-03 14:53
232 查看
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>简单练习,设置宽度</title>
<script type="text/javascript">
function f(o){
//alert(o.style.width);如果没有设置style则取值为空
oo.style.width = o.offsetWidth+10+"px";
//o.style.width = "200px";
}
</script>
</head>
<body>
<input id="i1" type="text" style="width:100px;" />
<input id="b1" type="button" value="change" onclick='f(i1);' />
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>简单练习,设置宽度</title>
<script type="text/javascript">
function f(o){
//alert(o.style.width);如果没有设置style则取值为空
oo.style.width = o.offsetWidth+10+"px";
//o.style.width = "200px";
}
</script>
</head>
<body>
<input id="i1" type="text" style="width:100px;" />
<input id="b1" type="button" value="change" onclick='f(i1);' />
</body>
</html>
相关文章推荐
- js改变style样式和css样式的简单实例
- 用js代码改变单选框选中状态的简单实例
- 用js代码改变单选框选中状态的简单实例
- js实现拖动改变层的大小(宽度)
- 获取元素长度、宽度并改变其值的js
- [JS]JS控制图片超过宽度自动缩小图片等比例缩放源代码实例
- 鼠标拖动动态改变表格的宽度的js脚本 兼容ie/firefox
- js根据浏览器的宽度不同改变CSS样式
- JS判断文本框内容改变事件的简单实例
- js 实现table每列可左右拖动改变列宽度
- js改变div宽度
- js实现左侧边栏可拖动改变显示区域宽度
- JS实现可改变列宽的table实例
- JS模仿编辑器实时改变文本框宽度和高度大小的方法
- js改变文章字体大小的实例代码
- 可拖动拉伸的左右分栏效果,本例子是用Table以及JS来实现的,左右分栏可改变,拖动中间的边框就可实现宽度的调整,点击时可设置为隐藏左侧列表。
- Vue.js点击切换按钮改变内容的实例讲解
- JS判断文本框内容改变事件的简单实例
- 原生JS获取元素集合的子元素宽度实例
- 鼠标拖动动态改变表格的宽度的js脚本 兼容ie/firefox