jquery 获取 p的width的语句:
$("#keleyi_com").width();
其中keleyi_com为p的id。完整示例代码:
<!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>jquery 获取 DIV的width(宽度)</title>
<script type="text/javascript" src="http://www.keleyi.com/keleyi/pmedia/jquery-1.8.3.min.js"></script>
</head>
<body>
<div id="keleyi_com" style="width:800px;border:1px solid silver">
本DIV的id为keleyi_com;<br />为欢迎访问PHP中文网
</div>
<script type="text/javascript">
$(document).ready(
function () {
alert("id为keleyi_com的width为:"+$("#keleyi_com").width());
}
)
</script>
</body>
</html>
Copyright © 2019- qugedi.com 版权所有
违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务