在這種情況下,具有ID“ target”的元素具有通過CSS設置為“無”的元素。但是,當使用$(“#target”)檢查其高度時。 If an element has an offsetWidth of 0 (considered "hidden" by jQuery), the library attempts to determine its height.
To accomplish this, jQuery temporarily applies the following properties to the element:
position: "absolute"visibility: "hidden"display:然後,使用getWidThorheight(...)檢索“ block”此機制使.height()/。 width()甚至在隱藏的元素上起作用,前提是他們的父元素可見。因此,您可以調用.height()/。 width(),而無需手動執行節目/隱藏序列,因為這些方法是通過這些方法內部處理的。
免責聲明: 提供的所有資源部分來自互聯網,如果有侵犯您的版權或其他權益,請說明詳細緣由並提供版權或權益證明然後發到郵箱:[email protected] 我們會在第一時間內為您處理。
Copyright© 2022 湘ICP备2022001581号-3