How to create javascript function for hovering 3 or 4 element at a time

前端 未结 2 1573
天涯浪人
天涯浪人 2021-01-27 22:37

I want to hover 3 item at a time. when i will put cursor one of them. It should hover other two item. please can help me anyone. i want to do this with javascript. I have make

2条回答
  •  自闭症患者
    2021-01-27 23:01

    1. use a mapping javascript object.

    2. and use class 'like' selector to bind functions to elements which have class starting with ".box"

    eg :

    $(document).ready(function(){
        var mapping = { 'box1':'box4','box4':'box1' };
    
        $("[class^=box]").mouseover(function(){
           .........
    
        });
    

提交回复
热议问题