オブジェクトが見つかったときにオブジェクトを返すはずのこの関数がありますが、そうしていません。私は何を間違っていますか?
var getEl = function(title){
var theInputs = $('input[type=text], input[type=radio], input[type=checkbox], select, textarea')
theInputs.each(function(){
if (this.title==title){
getEl = this
console.log('found it!')
}
})
}
console.log(getEl('Office Status'))
コンソールに出力されていることがわかったので機能することはわかっていますが、コンソールは次の行の出力として undefined を報告します。
console.log(getEl('Office Status'))