Question: I want to create loop in select box. But I want one code for different select.
I am able create for one select but I want for multiple .

for single: [with id](http://jsfiddle.net/rlemon/5J29g/) 

I want to change this code according class or for multiple select.
My code for this:

```
<select class="foo"></select><select class="foo"></select>

```

and:

```
$(document).ready(function() {
    var elm = document.getElementByClass('foo'),
    df = document.createDocumentFragment();
    for (var i = 0; i <= 60; i++) {
        var option = document.createElement('option');
        option.value = i;
        option.appendChild(document.createTextNode(" " + i));
        df.appendChild(option);
    }
    elm.appendChild(df);
});

```

Answer: 
Since you are using jQuery, so you could do like:

***[The demo.](http://jsfiddle.net/5fLGs/)***

```
$('.foo').each(function() {
    for (var i = 0; i <= 60; i++) {
        $('<option />').val(i).html('#option ' + i).appendTo($(this));
    }
});

```
You can use [class selector](http://api.jquery.com/class-selector/) along with [.append()](http://api.jquery.com/append/) and [.clone()](http://api.jquery.com/clone/)

```
$(document).ready(function () {
    var df = document.createDocumentFragment();
    for (var i = 0; i <= 60; i++) {
        var option = document.createElement('option');
        option.value = i;
        option.appendChild(document.createTextNode(" " + i));
        df.appendChild(option);
    }
    $('.foo').append(function () {
        return $(df).clone()
    })
});

```

Demo: [Fiddle](http://jsfiddle.net/arunpjohny/un7uV/)