cuốn sách gpt4 ai đã làm

javascript - jQuery .width()、style.width 和 jQuery .css ('width' 之间有什么区别?

In lại Tác giả: Hồ Xil 更新时间:2023-11-01 02:08:58 27 4
mua khóa gpt4 Nike

jQuery 的 .width()、jQuery 的 .css('width').style 返回的值有什么区别.width 节点上的属性?

我很好奇,因为在尝试将两个表格单元格的宽度设置为相等时,前两个给了我同样的错误答案。它们实际测量的是什么,为什么它与我在浏览器中查看元素时在 .style 属性中看到的值不同?

câu trả lời hay nhất

từ width 官方文档

The difference between .css(width) and .width() is that the latter returns a unit-less pixel value (for example, 400) while the former returns a value with units intact (for example, 400px). The .width() method is recommended when an element's width needs to be used in a mathematical calculation.

我会说 .css('width') 之间没有区别和 .style.with作为 css()方法用于设置样式对象属性。

.css('width')之间的区别/.width().style.with是 jQuery 方法使用 window.getComputedStyle( elem, null ) 获取计算样式.此方法用于在应用 CSS 和样式后读取实际属性。

关于javascript - jQuery .width()、style.width 和 jQuery .css ('width' 之间有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17494906/

27 4 0
Bài viết khuyến nghị: 窗口关闭事件上的javascript
Bài viết khuyến nghị: 不显示应用程序或场景的 javafx 快照
Bài viết khuyến nghị: java - Gson 中的 Stackoverflow 异常
Bài viết khuyến nghị: javascript - THREE.js 中的反光 Material
Hồ Xil
Hồ sơ

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá taxi Didi miễn phí
Phiếu giảm giá taxi Didi
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress