I am trying to do some things on a form element blur. The problem I’m having is passing the element’s info such as ID, class, etc to a second function. I’ve simplified it down for this example:
function otherfunction() {
var inputID = $(this).attr("id");
alert(inputID);
}
$(".formelement").blur(function () {
// Do some stuff here
otherfunction();
});
Of course, the alert box says that the inputID is undefined. How can I get the element’s info passed to the otherfunction?
Pass the input as an argument:
Or, use
Function.prototype.apply: