As you saw, this has a different meaning inside a setTimeout().
One solution is to store the correct value of this in a variable, and reference it in the anonymous function that you pass in.
$(function() {
$('li a').click(function() {
$(this).parent().css('background-position','left top');
var th = this;
window.setTimeout(function() {
$(th).css('font-size','40px');
},1000);
});
});
Another option is to use jQuery's $.proxy() which retains the value of this for you.
$(function() {
$('li a').click(function() {
$(this).parent().css('background-position','left top');
window.setTimeout($.proxy(function() {
$(this).css('font-size','40px');
}, this)
,1000);
});
});
Otherwise, you could create a closure.
$(function() {
$('li a').click(function() {
(function( th ) {
$(th).parent().css('background-position','left top');
window.setTimeout(function() {
$(th).css('font-size','40px');
}
,1000);
})( this );
});
});