$("body").on("click", "$[id *= ddlHour]",
function () {
ValidateDate();
}
);
This is working fine in jQuery 1.7.1 but when I upgrade to 1.12.4 it gives the following error:
Uncaught Error: Syntax error, unrecognized expression: $[id *= ddlHour]
I tried
$("body").on("click", "$('[id*=\"ddlHour\"]')",
function () {
ValidateDate();
}
);
but I am still getting the same error. Does anyone know what is going wrong?
I'm surprised that worked in an older version of jQuery, since the selector is invalid. That leading
$
shouldn't be there. It's just:More in the CSS specification.
Side note: Unless you explicitly want to prevent
ValidateDate
from receiving the event object that it would receive if it were hooked up directly, and/or want to preventValidateDate
returningfalse
to stop event propagation, you could just write: