jQuery : Get the number of options in a select box

Using jQuery to get the number of options in a select box
$('#mySelectBoxId option').length;

Using jQuery to get the number of options that are selected in a select box
$('#mySelectBoxId option:selected').length;

No comments:

Post a Comment

Python contextlib for Timing Python code

If you've ever found yourself needing to measure the execution time of specific portions of your Python code, the `contextlib` module o...