为什么80%的码农都做不了架构师?>>>
解决原生js获取兄弟节点或者子节点失效
1.写内联样式
<li class="mui-table-view-cell mui-col-sm-6 mui-col-xs-6">
<div class="fd-content" style="opacity:.1;">
<h5 class="mui-text-center mui-ellipsis-2 fd-title">打造最强独角兽公司的11个最强属性</h5>
<div class="mui-row mui-text-center">
<div class="mui-col-sm-4 mui-col-xs-4">
<a href="index.html" class="mui-icon mui-icon-eye"></a>
</div>
<div class="mui-col-sm-4 mui-col-xs-4">
<a href="index.html" class="mui-icon mui-icon-camera"></a>
</div>
<div class="mui-col-sm-4 mui-col-xs-4">
<a href="index.html" class="mui-icon mui-icon-email"></a>
</div>
</div>
</div>
<div class="fd-cover" style="top:0px;transform:scale(1);">
<img src="images/logo.png" alt=""/>
</div>
</li>
2.操作元素节点parentElement、previousElementSibling、nextElementSibling
mui("body").on("tap", ".fd-cover", function(){
var me = this;
var parameter = me.style.top;
var sibling = me.previousElementSibling;
if(parameter == "0px"){
me.style.top = "110px";
me.style.transform = "scale(1.2)";
sibling.style.opacity = "1";
}else{
me.style.top = "0px";
me.style.transform = "scale(1)";
sibling.style.opacity = "0.1";
}
me.style.transition = "all .5s ease-in-out";
sibling.style.transition = "all .5s ease-in-out";
});
mui("body").on("tap", ".fd-title", function(){
var me = this;
var opacitys = me.parentElement.style.opacity;
var sibling = me.parentElement.nextElementSibling;
if(opacitys == "1"){
me.parentElement.style.opacity = "0.1";
sibling.style.top = "0px";
sibling.style.transform = "scale(1)";
}
me.parentElement.style.transition = "all .5s ease-in-out";
sibling.style.transition = "all .5s ease-in-out";
});