George George - 2 years ago 138
Javascript Question

toggleClass not working in ajax

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();
url: "admin.php?user=" + user,
type: "GET",
beforeSend: function() {},
success: function(res) {
$("#results .name").toggleClass('.active');

Answer Source

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

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


$("#results .name").toggleClass('active');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download