I'm trying to select an Select Option throuh jQuery with a PHP variable.
HTML
<div id="dom-target">
<?php
$output = $user->distritos;
echo htmlspecialchars($output);
?>
</div>
jQuery
<script type="text/javascript">
var div = document.getElementById("dom-target");
var myData = div.textContent;
jQuery('select[name="country"]').find('option:contains(" + myData + ")').attr("selected",true);
</script>
But won't change, only if I replace option:contains(" + myData + ")
by text, for example option:contains("123")
it will select option with text "123"
What I'm doing wrong?
Thanks!