#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2017
    Posts
    3
    Rep Power
    0

    GetElementById( i need 3 IDs here)


    Hello guys.

    I need to use three IDs

    i tried this but its not working



    Code:
    document.querySelectorAll("#panel, #login, #showReg").onclick
  2. #2
  3. Wiser? Not exactly.
    Devshed God 2nd Plane (6000 - 6499 posts)

    Join Date
    May 2001
    Location
    Bonita Springs, FL
    Posts
    6,125
    Rep Power
    4103
    querySelectorAll returns an array of elements. You'd have to loop over the array and assign the onclick to each individual element. Or just call getElementById three times.
    Code:
    function yourClickHandler(){
       //...
    }
    
    document.getElementById('panel').onclick = yourClickHandler;
    document.getElementById('login').onclick = yourClickHandler;
    document.getElementById('showReg').onclick = yourClickHandler;
    Or use jQuery to make things easier.
    Code:
    JQuery('#panel, #login, #showReg').click(function(){
       //...
    });
    Recycle your old CD's



    If I helped you out, show some love with some reputation, or tip with Bitcoins to 1N645HfYf63UbcvxajLKiSKpYHAq2Zxud

IMN logo majestic logo threadwatch logo seochat tools logo