Clearing a Select
list:
$("#select_list_name").empty();
Adding an option in
Select List:
$("# select_list_name
").append($('<option>', {
value: value_to_add,
text: text_to_add
}));
Here ‘value_to_add’ & text_to_add aer values
that you want to be added.
To
Check if an option exist by value in a Select List:
if ($('#select_list_name).find('option[value='
+ value_to_search + ']').length > 0)
{
//When
an Item exist
}
Here value_to_search is the value that you want to
searched in select list.
To
select a particular value in select list after you find it:
$('#select_list_name).find('option[value=' + value_to_search + ']').attr("selected",
"selected");
To
read a selected value:
var selectedvalue = $("#select_list_name
option:selected").val();
To set
Margin value & Width for select list:
$('#select_list_name').css('margin-left', '5px');
$('#select_list_name ').css('width', (window.screen.width * 0.14) + 'px');
No comments:
Post a Comment