Home > Web Front-end > JS Tutorial > body text

Implementation ideas and code for jquery to obtain div width

PHP中文网
Release: 2016-05-16 17:43:51
Original
1059 people have browsed it

How to get the width of p? Next, we will introduce how to use jquery to get the width of p. Interested friends can learn about

jquery statement to get the width of p:

$("#keleyi_com").width(); 
其中keleyi_com为p的id。
Copy after login

Full sample code:

<!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>
Copy after login


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template