When I refresh page always show you selected, why?
Thanks.
if ($("#users option:selected"))
{
alert('you selected');
}
<select name = "users" id = "users">
<option value="0">text</option>
</select>
When I refresh page always show you selected, why?
Thanks.
if ($("#users option:selected"))
{
alert('you selected');
}
<select name = "users" id = "users">
<option value="0">text</option>
</select>
jQuery will always return an object, even if it is empty, so your conditional will always execute regardless of anything being selected or not. Use a check on length instead.
if ($("#users option:selected").length > 0)