Please see my example here: LIVE EXAMPLE
*As you can notice, the focused on input is not the first empty one. What is wrong? *
jQuery Code:
$(document).ready(function() {
$('.quick div input, .quick div textarea').live('focus', function() {
var a = $(this).attr('id');
var b = 'submit';
$('.quick .focus').removeClass('focus');
if (a == b) {
return false;
} else {
$(this).parent().addClass('focus');
}
});
$('input:text[value=""]').focus(); // problematic line
});
You have to use
:first. As you are not using:first, it is going through every<input type="text" value=""..and it is stopping at the at last one. Code below will work for youWorking demo http://jsfiddle.net/usmanhalalit/Y8d4f/34/