I want to select an HTML element (form) which does not have a specific class ('Ajax_Stop'), so that I can implement a jQuery function on that, basically when submitting a form I want to check if a form or div doesn't have that specific class using jQuery-javascript, & run a function if it doesn't have that CSS class.
How to do it using jQuery or javascript?
You can use jQuery's :not() function,suppose you want form or div which does not have class .Ajax then your jQuery code will be
$("form:not(.Ajax)").on('submit',function(){
//do soemthing
});
that's it
jQuery has the .hasClass() function that returns true if any element has that specified class, so if it doesn't have, it will return false, and you can use it like
if (!$("form#FormId").hasClass("Ajax")) {
//something here
}
So this will also work for you, and above answer by @neena is another method
You can also use jQuery method .not()
$('form').not('.Ajax');
here is the short description of the jQuery selectors:
[attribute]
[attribute=value]
[attribute!=value]
Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly