This should I believe be $.prop rather than $.attr - please check with jQuery docs