views:

87

answers:

2

If I use this

$("select option").attr("selected", "true");

Or

$(function(){
    $('select').children('option').attr('selected', 'selected');
});

the list of dropdown will be selected automatically.

But in my position I should not use Iterator. Here both function using iterator. Here each and every option we set true or selected through iterator.

I need like if I set true to object of list, all the value of list should be selected without using loop or iterator.

A: 

The difference between selected="true" and selected="selected" is that one is for HTML and the other is for XHTML.

In HTML you use selected="true" (You used to just use selected, with no value, but using selected="true" is more explicit).

$("select option").attr("selected", "true");

In XHTML you use selected="selected"

$("select option").attr("selected", "selected");
Sohnee