Link to home
Avatar of Neil_Bradley
Neil_BradleyFlag for New Zealand

asked on

getElementById and getElementByClassName

The snippet here checks to see if the browser is mobile then adds type="date" to the 2 specified input fields.
    if(isMobile ) {
            document.getElementById('date1').type = 'date';
	        document.getElementById('date2').type = 'date';
        } else {

Open in new window

It works great.
Problem is I need to change the script to look for a class and not an id however I'm not having much look with he following
document.getElementsByClassName('date-pick').type = 'date';

Open in new window

Would really like to get this working so assistance approciated
ASKER CERTIFIED SOLUTION
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
SOLUTION
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of Neil_Bradley

ASKER

Thanks both. Worked perfectly..
Cheers,
Neil