Try using .filter()
, to find the option you want.
$('option').filter(function(){
return $(this).html() == "<?php echo $_SESSION['divelevel'];?>";
}).attr('selected', 'selected');
More Related Contents:
- jQuery Adding new option to select element doesn't pick up the string [closed]
- jQuery get value of select onChange
- Why does the jquery change event not trigger when I set the value of a select using val()?
- Use jQuery to change a second select list based on the first select list option
- Click event on select option element in chrome
- How do I make jQuery Contains case insensitive, including jQuery 1.8+?
- jQuery: Best practice to populate drop down?
- Auto resizing the SELECT element according to selected OPTION’s width
- Best way to unselect a in jQuery?
- How to make the first option of selected with jQuery
- jQuery :contains selector to search for multiple strings
- jQuery if div contains this text, replace that part of the text
- Selecting text on focus using jQuery not working in Safari and Chrome
- Populate Select box options on click with Javascript/Jquery with Json data
- Get index of selected option with jQuery
- Get SELECT’s value and text in jQuery [duplicate]
- Jquery- Get the value of first td in table
- Disable select options based on value *through the HTML only!*
- Unselect what was selected in an input with .select()
- jQuery onchange/onfocus select box to display an image?
- Pass request headers in a jQuery AJAX GET call
- twitter bootstrap typeahead ajax example
- jQuery Validate – require at least one field in a group to be filled
- Update div with jQuery ajax response html
- How to make Bootstrap carousel slider use mobile left/right swipe
- The $ dollar sign
- Open JQuery Datepicker by clicking on an image w/ no input field
- Typescript “this” inside a class method
- Set background colour of select to selected option in JQuery
- handle ajax error when a user clicks refresh