Why does the software selection of an option in select work only once? Code:
$(document).ready(function() { $("#default").attr('selected', 'selected'); }); $("button").click(function(){ $("select option:contains('two')").attr('selected', 'selected'); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> <select> <option>----------</option> <option id="default">one</option> <option>two</option> <option>three</option> </select> <button>set two</button> Now I guess ... What could be the reason?
val(...)to set, get the value - Grundyvalmethod does not always work, you change it to thepropmethod and it copes. apparently they are not the same. With this string "02.20.11.114 Cedar logs for sawing and planing" and the connected select2 plugin, thevalmethod failed. - perfect