toggleClass not working in ajax

本秂侑毒 提交于 2021-02-05 06:09:49

问题


Hello Im new on stackoverflow, i have this GET method its work fine i mean i get a respone from server but i toggleClass is not working i dont know why ?

this is my code:

$("#form1").on("click", function() {
  var user = $("#form1 input.user").val();
  $.ajax({
    url: "admin.php?user=" + user,
    type: "GET",
    beforeSend: function() {},
    success: function(res) {
      $("#results").html(res);
      $("#results .name").toggleClass('.active');
    }
  });
});

回答1:


you dont need a dot just remove it from your code change

$("#results .name").toggleClass('.active');

to

$("#results .name").toggleClass('active');


来源:https://stackoverflow.com/questions/36668285/toggleclass-not-working-in-ajax

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!