Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <select id="mySelect" multiple="multiple">
- <option value="1">First</option>
- <option value="2">Second</option>
- <option value="3">Third</option>
- <option value="4">Fourth</option>
- </select>
- <script type="text/javascript">
- $(document).ready(function() {
- if (!$("#mySelect option:selected").length)
- $("#mySelect option[value='3']").attr('selected', 'selected');
- });
- </script>
- var foo = document.getElementById('yourSelect');
- if (foo)
- {
- if (foo.selectedIndex != null)
- {
- foo.selectedIndex = 0;
- }
- }
- function selectOption(select_id, option_val) {
- $('#'+select_id+' option:selected').removeAttr('selected');
- $('#'+select_id+' option[value='+option_val+']').attr('selected','selected');
- }
- <script type="text/javascript">
- $(document).ready(function() {
- if (!$("#mySelect option:selected").length)
- $("#mySelect").val( 3 );
- });
- </script>
- $("#mySelect").val( 3 );
- $(".Result").html($("option:selected").text());
- $(document).ready(function(){
- if ( $("#context").selectedValues() == false) {
- $("#context").selectOptions("71");
- }
- });
- $("option[value*='2']").attr('selected', 'selected');
- // 2 for example, add * for every option
Add Comment
Please, Sign In to add comment