Skip to main content

How to select the first option in a combo box?

Published 1 min readMarkdown

Simply in jQuery (a Javascript framework - Write less, do more):

$("#div_id option:first).attr("selected","selected");

Example:

$('#myCombo').load( 'my_combo.php?foo=bar', function() { $('#myCombo option:first).attr("selected","selected"); } ); html:

About the author

  • Khanh is a full stack web developer with over 15 years of experience developing for the web

No comments yet. Be the first to comment.

More from this blog