Hi
I'm trying to attach a simple focus/blur event listener via the .live()
jQuery method to my inputs but what I'm noticing is that the focus
event is not firing whereas the blur
event is.
Strange… was hoping you may have an idea of why this is happening.
Here is the code:
function rowHighlight() {
var form = $('form.register'),
ele = {};
form.find('label').each(function(i) {
var link = this.htmlFor;
form.find('label[for='+link+'],input[name='+link+'],textarea[name='+link+']').wrapAll('<span class="row"/>');
});
ele.row = $('form > .row');
ele.inputs = ele.row.find('input');
$.each(ele.inputs, function(i) {
$(this).focus(function() {
console.log('hello'); // this will fire.
});
$(this).live('focus blur', function(e) {
console.log('current event type: '+e.type); // the focus on this will not fire!?
( e.type=='focus' ? console.log('focussed') : console.log('blurred') )
});
});
}
rowHighlight();
$(this).focus…
was just put it as a debugging thing and removing it does not make the focus
on the live
listener work…
Any help would be appreciated.
Thanks for stopping by.
Jannis