your html definition uses div.col.md-3
but your js uses col-md-3
so first check for typos.
Next, var Contenz = Quiz.document.getElementById('page-content');
will return an error Uncaught TypeError: Cannot read property 'getElementById' of undefined
, so if var Quiz = document.getElementById('page-mod-quiz-attempt')
is not needed. Just use var Contenz = document.getElementById('page-content');
Then, Contenz.getElementsByClassName('col-md-3');
returns an array with the class. so Contenz.getElementsByClassName('col-md-3').className;
is undefined. Instead Contenz.getElementsByClassName('col-md-3')[0]
will be the html that is using that class.
Finally you have this:
var Contenz = document.getElementById('page-content');
Contenz.getElementsByClassName('col-md-3')[0].className += ' col-xs-12 col-sm-12';
Which will do what you were asking.
https://jsfiddle.net/onbjhppm/2/
UPDATE: per the comment form OP
If you need to use id="page-mod-quiz-attempt" as the unique identifier, do this instead:
var Quiz = document.getElementById('page-mod-quiz-attempt');
Quiz.getElementsByClassName('col-md-3')[0].className += ' col-xs-12 col-sm-12';
https://jsfiddle.net/onbjhppm/3/
Or else add a class identifier to id="page-content" element and chain getElementsByClassName to get to the one you want
Note: getElementById
is only available on document
. In order to chain them you will have to create your own function chaining getElementById