<p>Using <a href="http://en.wikipedia.org/wiki/JQuery" rel="noreferrer">jQuery</a>, how can I dynamically set the size attribute of a select box?</p>

<p>I would like to include it in this code:</p>

<pre><code>$("#mySelect").bind("click",
    function() {
        $("#myOtherSelect").children().remove();
        var options = '' ;
        for (var i = 0; i &lt; myArray[this.value].length; i++) {
            options += '&lt;option value="' + myArray[this.value][i] + '"&gt;' + myArray[this.value][i] + '&lt;/option&gt;';
        }
        $("#myOtherSelect").html(options).attr [... use myArray[this.value].length here ...];
    });
});
</code></pre>

[{'answer_id': 65239, 'author': 'Loren Segal', 'author_id': 6436, 'author_profile': 'https://Stackoverflow.com/users/6436', 'pm_score': 6, 'selected': True, 'text': "<p>Oops, it's</p>\n\n<pre><code>$('#mySelect').attr('size', value)\n</code></pre>\n"}, {'answer_id': 65261, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 1, 'selected': False, 'text': '<pre><code>$("#mySelect").bind("click", function(){\n    $("#myOtherSelect").children().remove();\n    var myArray = [ "value1", "value2", "value3" ];\n    for (var i = 0; i &lt; myArray.length; i++) {\n        $("#myOtherSelect").append( \'&lt;option value="\' + myArray[i] + \'"&gt;\' + myArray[i] + \'&lt;/option&gt;\' );\n    }\n    $("#myOtherSelect").attr( "size", myArray.length );\n});\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/65206', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2755/']