There is the code $("#d3").click(function(){ $(this).toggleClass('my3d'); $("a").removeAttr("class"); $(".main-cube").css("top", "10%"); $(".cube").css({width: "95vw", height: "45vh"}); $(".side").css({position: "static", transform: "none", width: "95vw", height: "90vh"}); });

In it, I specifically need to remove the class attribute from the links so that it does not activate the rotation of the shape. That is, when you click on the link, nothing happens. But for some reason attribute removal does not work. When you click for example on aa with the class link2, the rotation of the shape starts (in another jQuery code), in spite of any of my witchcraft. How is that???

Here is the HTML code to which I want to apply the removal:

 <ul class="main-menu loft-mnu"> <li><a class="link1" href="#side1">Главная</a></li> <li><a class="link2" href="#side2">О компании</a></li> <li><a class="link3" href="#side3">Услуги</a></li> <li><a class="link4" href="#side4">Заказать сайт</a></li> <li><a class="link5" href="#side5">Цены</a></li> <li><a class="link6" href="#side6">Контакты</a></li> </ul> 

"Other Code"

  $(".link2").on("click", function() { $('.side') .animate({ width: "600px" }, 1000 ) .animate({ height: "600px" }, 1000 ); $(".cube").css({width: "600px", height: "600px", left: "0"}); setTimeout (function () { $('.cube').css("transform", "rotate3d(0,1,0,270deg)"); }, 2500 ); setTimeout (function () { $(".cube").css({width: "95vw", height: "45vh"}); $('.main-cube').css({top: "10%", perspective: "2000px"}); $('.side2') .animate({ width: "95vw" }, 1000 ) .animate({ height: "90vh" }, 1000 ); }, 5000 ); }); 
  • "attribute removal does not work" - how do you know? Is the handler for link clicks already hung up? - Igor
  • because my figure keeps spinning anyway - Vladimir Abramovich
  • maybe should show the "other" code? Or do you think that telepaths are sitting here? - Igor
  • the handler binds to the element, not to the class. After binding, the element still has some class or not. - Grundy

1 answer 1

$(document).on("click", ".link2", function() { ...

Update

Well, add to the handler:

 $(".link2").on("click", function() { if (!$(this).hasClass("link2")) return; ... } 

Update 2

Please return the question to the original form and ask another.

And please do not write

return (someNumber % 2 === 0) ? true : false;

and

if (isEven(count) === false) {

Write

 var isEven = function(someNumber) { return someNumber % 2 === 0; }; if (!isEven(count)) { ... } else { ... } 

What is the meaning of the line

$(".main-menu a").attr("class"); ?

  • but then the rotation does not work. I will have a 3-dimensional figure in the code, which, when pressed on the topmost code, expands into a two-dimensional one. So, the three-dimensional should rotate and unfold according to the last code, and in the 2-dimensional, the a class attribute should be deleted. - Vladimir Abramovich
  • Good, thank you very much! - Vladimir Abramovich
  • interesting question :) and how to return the class attribute back? - Vladimir Abramovich
  • @ VladimirAbramovich at what moment? - Igor
  • At the moment of repeated pressing on # d3. Now I will place it at the top an additional code - Vladimir Abramovich