On my pages after a postback I am trying to return focus to a previously focused element
$(window).load(function()
{
$('.focus').focus();
});
$(document).ready(function()
{
$('input:not([type=button],[type=submit]), select, textarea').focus(function()
{
$(this).addClass('focus');
});
$('input:not([type=button],[type=submit]), select, textarea').blur(function()
{
$(this).removeClass('focus');
});
});
My code looks like this and it works even for nested elements but looks a little awkward to me, I am just wondering if there is a better/more optimal way of doing it?