Jquery,获取样式:背景(不是背景颜色)、边框等,无法弄清楚如何做到这一点
看来firefox会自动组合一些东西,例如它采用单独的css值,例如“border-color”,“border-width”并将它们全部转储到“border”中。这使得jquery变得很痛苦,因为. css选择器只能选择单个的,例如“边框颜色”,而不仅仅是“边框”或“背景”。我需要获取“边框”或“背景”的完整值,以便我可以解析它以获取我需要的值..我已阅读其他帖子并尝试了以下操作,但它没有返回值:
test = $("#mydiv").attr("border");
任何建议表示赞赏
It seems that firefox automatically combines things, such as it takes individual css values, such as for "border-color", "border-width" and dumps them all into "border".. this makes things a pain for jquery as the .css selector can only select the individual ones, like "border-color", not just "border" or "background".. I need to get the full value of "border" or "background" so that I can parse it to get the values I need.. I have read other posts and have tried the following but its not giving back the value:
test = $("#mydiv").attr("border");
Any advice is appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想你想这样做:
编辑:好的,你可以使用普通的旧 JavaScript:
I think you want to do this instead:
EDIT: ok you can use plain old javascript: