问题
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