Jquery Selecting Option From June 27, 2022 Post a Comment I have the following option box: Input #1: Miner Solution 1: Use .val() to set select value by option value: $("#inputselection1").val(4); Copy If you insist on selecting by text, then use this: $("#inputselection1 option").filter(function() { return $(this).text() === 'Max'; }).attr("selected", "selected"); Copy Solution 2: If you want to select by option text you can use a filter function $("#inputselection1 option").filter(function() { return $(this).text() === 'Max'; }).prop("selected", true); Copy Fiddle Solution 3: $("#inputselection1 option[value=4]").attr("selected","selected"); taken from jQuery Set Select Index Share Post a Comment for "Jquery Selecting Option From"
Post a Comment for "Jquery Selecting Option From"