解决原生js获取兄弟节点或者子节点失效

为什么80%的码农都做不了架构师?>>>   hot3.png

解决原生js获取兄弟节点或者子节点失效

 

1.写内联样式

  •     

            

    打造最强独角兽公司的11个最强属性

            

                

                    

                

                

                    

                

                

                    

                

            

        

        

            

        

  • 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";

    });

     

    转载于:https://my.oschina.net/af666/blog/847712

    你可能感兴趣的:(解决原生js获取兄弟节点或者子节点失效)