gpt4 book ai didi

jquery - 如何使用选择器获取元素的值

转载 作者:太空宇宙 更新时间:2023-11-03 20:57:42 24 4
gpt4 key购买 nike

例子:

$(document).ready(function(){    

height = $('#container-bottom:before').height();
alert(height);

});

警报 null(当然我知道该值不是 null)。

最佳答案

不幸的是,CCS 伪元素(如 :before:after)不是 DOM 的一部分(尽管它们被渲染得好像它们是)——因此它们不能用 jQuery 操作。

参见:Selecting and manipulating CSS pseudo-elements such as ::before and ::after using jQuery

关于jquery - 如何使用选择器获取元素的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8221326/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com