jquery - Why do we write .attr('selected','selected') with select tag

attr, jquery, select, selected

Solution

Explanation of `.attr('selected','selected')`.

First argument inside `.attr` represent the `attribute` you want to pointing at while second argument set `value` of attribute which is passed as first argument.

if we have just `.attr('selected')` then it just return the value of `selected` attribute.

Problem

why do we write `.attr('selected','selected')` with select tag For ex: ``` $('#countryList option').filter(function () { return ($(this).text() == findText); }).attr('selected','selected'); }); ``` What does it really means?

Original source