react 点击事件获取当前dom元素并修改其和其兄弟节点的样式

js源码:

    choose = (e)=>{

        // 获取该dom节点

        console.log(e.currentTarget)

        // 改变该dom节点的样式

        e.currentTarget.style.backgroundColor="red";

        // 对该dom节点的兄弟节点操作

         $(e.currentTarget).siblings().css("background-color","pink");  

    }

html源码:

                                    

this.choose(e)}>1

                                    

this.choose(e)}>2

                                    this.choose(e)}>3

 

你可能感兴趣的:(react)