Im having problems with trying to set a select option to “selected”, it does not seem to work
jquery
<script>
$(function(){
$(document).ready(function(){
$("select[name=searchType] option[value=title]").attr("selected", "selected");
});
});
</script>
html markup
<select name="searchType">
<option value="isbn">ISBN</option>
<option value="title">Title</option>
<option value="author">Author</option>
</select>
What could be causing this problem?
Try
also, check if your selector returns the element