Jquery - Get all the option fields of a select and save the value and id and compare with var string and is inside : I have a select with several option, each option has an id and the value.

This select is loaded with an ajax in jquery.

There is also a string variable that contains a text, with which you would have to compare all the option values and if any of them are within this text, select the option value as selected.

Example:

    var mytexto = 'Ipad Mini 4 16GB/1GB Azul';

    <select id="nombre_modelo" class="form-control">
     <option value="" disabled="disabled" selected="selected">Select one model name</option>
     <option id="25">Ipad 3</option>
     <option id="26">Ipad 4</option>
     <option id="27">Mini 4</option>
     <option id="28">Mini Wifi A1403</option>
     <option id="29">Mini Wifi A1432</option>
    </select>
In this example you would have to get the id = '27 'and the value =' Mini 4 'of "<option id="27"> Mini 4</option>" which is the one inside the string.

How do I get these two values, the id and the value?