views:

28

answers:

1

Is there any way in jquery to access the options length of combobox? I'm trying to change this line

cmbBox.options.length = 0;

with a jquery syntax.

+1  A: 

Why is there a need to use jQuery syntax? jQuery is merely a JavaScript framework that is meant to make development easier, but when something is already easy in JavaScript, why use jQuery??

Anyway, you can retrieve the length of a jQuery nodelist you can simply use the length method:

var len = $('#cmbBox option').length():
Jacob Relkin
Thanks for the answer, i think the last call should be length only not length().Browser compatibility is one of the reasons why I use jquery.
penguru
What about if combobox is a variable like $cmbBox ? What is the syntax in this situation ?
penguru
Also I want to set the length value, not only get..
penguru