这个 内宽 是jQuery中的一个内置方法,用于返回第一个匹配元素的宽度。 语法:
null
$(selector).innerWidth()
这里的选择器是选定的元素。 参数: 它不接受任何参数。 返回值: 它返回选择器的宽度。 显示innerWidth()方法工作的jQuery代码:
<!DOCTYPE html> < html > < head > < script </ script > < script > <!--jQuery code to demonstrate innerWidth function --> // document ready $(document).ready(function() { // on clicking the paragraph $("p").click(function() { // innerWidth document.getElementById("demo").innerHTML = "innerWidth = " + $("div").innerWidth(); }); }); </ script > </ head > < body > < div style = "height: 100px;width: 200px; background-color: blue" > </ div > < p >Click here to know innerWidth</ p > < p id = "demo" ></ p > </ body > </ html > |
输出: 在点击段落之前-
点击段落后-
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END