One function to toggle multiple hidden elements?

后端 未结 3 630
粉色の甜心
粉色の甜心 2021-01-26 12:55

This is just a snippet but I will have many different links on a page. Each link will have a different hidden element associated with it. I\'m trying to avoid writing 100 diff

3条回答
  •  醉酒成梦
    2021-01-26 13:19

    You may use given below toggle function to toggle multiple elements by giving array of element id as input.

    For example:

         toggleElements(["elem1","elem2"],["elem3"]);
         OR
         toggleElements(arr1,arr2);
    
    function showElements(showEls){
           for(var i=0; i

提交回复
热议问题