Seting select index in jQuery

$('#myselect option:eq(1)').attr('selected', 'selected');

This will select the first option

 

To deslect it do not use null ( as in attr('selected', null)) but rather use removeAttr as in

$('#myselect option:eq(1)').removeAttr('selected');

Print | posted @ Wednesday, November 3, 2010 9:42 AM

Comments on this entry:

No comments posted yet.

Post A Comment
Title:
Name:
Email:
Comment:
Verification: