У меня есть функция mouseover, которая должна добавить класс к моему элементу viewport, но я получаю сообщение об ошибке в firebug при наведении мыши: TypeError: jQuery (. ). addclass не является функцией.
addClass нужен капитал «C».
Кроме того, при добавлении класса вам не нужно указывать «.». в строке или вашем классе будет ..viewporthome .
Используйте addClass вместо addClass
Удалите лишнюю точку и используйте addClass() не addclass()
Проверьте свою капитализацию. Метод addClass имеет значение «C».
Если изображение все еще не отображается, это, вероятно, проблема с относительным путем к вашему изображению. Если папка с изображениями находится не в том же каталоге, что и в вашем файле Javascript, вам может потребоваться изменить путь. Я не могу точно сказать, что вам нужно будет сделать, не зная структуру вашего каталога.
I have a mouseover function that should add a class to my viewport element, but i get an error in firebug when I mouseover: TypeError: jQuery(. ).addclass is not a function.
The related styles are:
closed as too localized by Felix Kling, fotanus, Cairnarvon, Pete, Peter Ritchie Jun 2 ’13 at 2:01
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldw >If this question can be reworded to fit the rules in the help center, please edit the question.
5 Answers 5
addClass need a capital «C».
Also, when adding class, you dont need to put the «.» in the string or your class will be ..viewporthome .

Use addClass instead of addclass
Removing a class:

Remove extra dot and use addClass() not addclass()
Check your capitalization. The addClass method has a capital ‘C’.
If the image still isn’t showing up it is probably an issue with the relative path to your image. If the images folder isn’t in the same directory as your Javascript file you may have to modify the path. I can’t tell exactly what you would need to do without knowing your directory structure.
I want to get the ID of the clicked anchor and add a class to the element with same ID.
Uncaught TypeError: o.addClass is not a function.
1 Answer 1
This code is the problem:
$galleryProjectContent is a string, not a jQuery object or a DOM element.
I want to get the ID of the clicked anchor and add a class to the element with same ID.
There’s no reason to get the ID and then look up the element with the ID, you already have the element: this . It has to be the element you’re looking for (since id values must be unique on the page). To get a jQuery wrapper for it, just use $(this) . So simply:
If you needed to get an element by an ID that you have as a string, you could do it like this:
But again, there’s no reason to do that here.