阅读边框颜色值形式parent's background-color,透明parent's backgr
Reading border color value form parent's background-color, and transparent parent's background-color
我有一个div,如何从父元素的背景颜色中获取它的边框颜色,并透明父元素的背景颜色。
e.x。代码是这样的:
<div class="parent">
<div class="child">
</div>
</div>
<style>
.parent {
background-color: #333;
}
.child {
border-color: #fff;
}
</style>
现在,我想让子边框的颜色变成#333(父边框的颜色),并且父边框的背景色(#333)变成透明。
我想基于父子关系而不是div的名称来做
用父元素的background-color改变子元素的border-color
var child = $('.child');
child.css({
'border-color': child.parent().css('background-color')
});
将父元素的background-color改为transparent
child.parent().css('background-color', 'transparent');
您是否需要对多个元素执行此操作?
相关文章:
- jQuery parent() in table
- iFrame parent node
- Javascript TypeError:$(..)parent不是函数
- parent和iframe中的Bootstrap.js文件
- 如何捕获jqueryDialog和Parent之间的交互
- 如何从DOM(KnockoutJS)中删除$data、$parent等
- 在angular中使用$parent是一种好的做法吗
- 从 Childe 到 Parent ASP 的变量
- this.constructor.apply vs this.parent.apply
- 在JQuery中使用parent()和children()方法的缺点
- 如何在jquery中创建函数和parent.function
- jQuery parent或parents以获取表th标记中的数据属性
- Window.parent and Window.top returning null
- jQuery:如何正确选择parent.prev
- Parent() UL of div
- positon元素相对于JS中的parent.part容器?没有绝对/固定的定位
- 脏表单 - 如何忽略在parent.window.location.href上弹出的脏表单
- 从iframe调用Parent函数,然后更新iframe表单值
- 创建一个类似datatables.net的表示例,其中包含parent/child和+/-响应按钮
- Parent-Iframe postMessage communication