D
D
Dmitry Petrov2015-04-23 22:27:12
css
Dmitry Petrov, 2015-04-23 22:27:12

How to add a class to an object on click?

Hello. I can't figure out why this is the code:

nextSlide = function () {
    var slide = document.getElementById("scalable");
    slide.classList.add("outDown");
};

Throws an error:

Uncaught TypeError: Cannot read property 'classList' of null

I would like to know why the error occurs...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
rmaksim, 2015-04-23
@krutoo

there is no your "scalable" in jsfiddle.net/dk5g30jv/2 page

D
danilduck, 2015-04-23
@danilduck

onclick="$(this).addClass('класс');"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question