Can someone help me understand this line of jquery code?:
$(this).find('input[type="submit"]:not(.cancel), button').click(function ()
I'm particularly interested in .cancel
, since the whole chunk of jquery code (not included here) is being used to validate a page and I'm trying to prevent the validation if the user clicks on the cancel button. I'm guessing the above line of code is saying it the submit button clicked is NOT the cancel button, then continue.
But I don't know how to designate a button as cancel.
Sometimes the problem is caused by old versions of the Javascript files, cached by your browser and can be fixed by clearing the browser cache. You can use the browser console of your browser for debugging. After the Javascript error is fixed, the submit button will automatically be enabled.
activeElement will give you the submit button that was clicked. document. activeElement. getAttribute('value') will give you that button's value.
The default value for the type attribute of button elements is "submit". Set it to type="button" to produce a button that doesn't submit the form. In the words of the HTML Standard: "Does nothing."
Basically it is looking for elements located within this
that has the following requirements
cancel
OR
Good answers here. Perhaps this annotated version adds some value.
$(this) // within this jQuery object
.find(' // find all elements
input[type="submit"] // that are input tags of type "submit"
:not(.cancel) // and do not have the class "cancel"
, // or
button // are button elements
')
.click( // and for each of these, to their click event
function (){} // bind this function
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With