Example

<select id="fruit">
    <option value="">--select--</option>
    <option value="1">apple</option>
    <option value="2">pineapple</option>
    <option value="3">orange</option>
<select>
<br>
<button>apple</button>
<button>orange</button>
<button>pineapple</button>

$(function() {
    $("button").click(function() {
        $("#fruit option:contains('" + $(this).text() + "')").attr("selected", true);
    })
})


'js' 카테고리의 다른 글

ajax 기본 틀  (0) 2017.11.10
input 선택된 값 가져오기  (0) 2017.11.07
마우스 클릭 이벤트 (자동클릭)  (0) 2017.05.11
jquery selector  (0) 2017.05.01
url에 한글 주소 포함시킬 때  (0) 2017.04.11

WRITTEN BY
carbo

,