vendredi 31 juillet 2015

Set select value based on h1 text

I have the following form:

$(function() {
    if () {}
    else {}
});

<script src="http://ift.tt/1oMJErh"></script>
<h1>Sandeep</h1>
<form>
    <select>
        <option>Non Selected</option>
        <option selected>Michael</option>
        <option>Sandeep</option>
    </select>   
</form>

I want to find a way to say in javascript: if the text of the h1 is Sandeep the option selected will be sandeep.

I don't know how to define the condition inside the if statement. Any ideas?

Aucun commentaire:

Enregistrer un commentaire