In my previous question a poster suggested the following:
var formSubmitHandler = function (link, form) {
var $form = $(form);
var val = $form.valid();
var action = $form.data('action');
var entity = $form.data('entity');
I understand now that the $ before is used to show the variable is a jQuery object. My question is Why do I need the line “var $form = $(form)” ? Could I not just have $form = form?
formis the dom element,$formis a jQuery object selecting said dom element. jQuery has cool functions one can perform, the dom element has differnet functions and properties. Consider this utterly unrelated example:html:
javascript:
Note how the jQuery
.html()function is different than the dom.innerHTMLproperty.