jQuery로 선택된 값 읽기
$("#select_box option:selected").val();
$("select[name=name]").val();
jQuery로 선택된 내용 읽기
$("#select_box option:selected").text();
선택된 위치
var index = $("#test option").index($("#test option:selected"));
-------------------------------------------------------------------
$("#myselect").append("<option value='1'>Apples</option>");
$("#myselect").append("<option value='2'>After Apples</option>");
// Add options to the start of a select
$("#myselect").prepend("<option value='0'>Before Apples</option>");
// Replace all the options with new options
$("#myselect").html("<option value='1'>Some oranges</option><option value='2'>More Oranges</option><option value='3'>Even more oranges</option>");
// Replace items at a certain index
$("#myselect option:eq(1)").replaceWith("<option value='2'>Some apples</option>");
$("#myselect option:eq(2)").replaceWith("<option value='3'>Some bananas</option>");
// Set the element at index 2 to be selected
$("#myselect option:eq(2)").attr("selected", "selected");
// Set the selected element by text
$("#myselect").val("Some oranges").attr("selected", "selected");
// Set the selected element by value
$("#myselect").val("2");
// Remove an item at a particular index
$("#myselect option:eq(0)").remove();
// Remove first item
$("#myselect option:first").remove();
// Remove last item
$("#myselect option:last").remove();
// Get the text of the selected item
alert($("#myselect option:selected").text());
// Get the value of the selected item
alert($("#myselect option:selected").val());
// Get the index of the selected item
alert($("#myselect option").index($("#myselect option:selected")));
// Alternative way to get the selected item
alert($("#myselect option:selected").prevAll().size());
// Insert an item in after a particular position
$("#myselect option:eq(0)").after("<option value='4'>Some pears</option>");
// Insert an item in before a particular position
$("#myselect option:eq(3)").before("<option value='5'>Some apricots</option>");
// Getting values when item is selected
$("#myselect").change(function() {
alert($(this).val());
alert($(this).children("option:selected").text());
});
댓글 1개
13년 전
좋네요
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7230 | 11년 전 | 3637 | ||
| 7229 | 11년 전 | 3760 | ||
| 7228 | 11년 전 | 3801 | ||
| 7227 | 11년 전 | 3923 | ||
| 7226 | 11년 전 | 2374 | ||
| 7225 | 11년 전 | 17462 | ||
| 7224 |
AngryDev
|
11년 전 | 1369 | |
| 7223 |
돌아온깡통
|
11년 전 | 1121 | |
| 7222 |
돌아온깡통
|
11년 전 | 1063 | |
| 7221 |
돌아온깡통
|
11년 전 | 894 | |
| 7220 |
돌아온깡통
|
11년 전 | 1015 | |
| 7219 |
돌아온깡통
|
11년 전 | 845 | |
| 7218 |
돌아온깡통
|
11년 전 | 676 | |
| 7217 |
돌아온깡통
|
11년 전 | 1061 | |
| 7216 |
돌아온깡통
|
11년 전 | 804 | |
| 7215 |
돌아온깡통
|
11년 전 | 722 | |
| 7214 |
돌아온깡통
|
11년 전 | 1071 | |
| 7213 |
돌아온깡통
|
11년 전 | 939 | |
| 7212 |
돌아온깡통
|
11년 전 | 723 | |
| 7211 |
돌아온깡통
|
11년 전 | 886 | |
| 7210 |
돌아온깡통
|
11년 전 | 908 | |
| 7209 |
돌아온깡통
|
11년 전 | 905 | |
| 7208 |
돌아온깡통
|
11년 전 | 1018 | |
| 7207 |
돌아온깡통
|
11년 전 | 634 | |
| 7206 |
돌아온깡통
|
11년 전 | 696 | |
| 7205 |
돌아온깡통
|
11년 전 | 878 | |
| 7204 |
돌아온깡통
|
11년 전 | 742 | |
| 7203 |
돌아온깡통
|
11년 전 | 752 | |
| 7202 |
돌아온깡통
|
11년 전 | 733 | |
| 7201 |
돌아온깡통
|
11년 전 | 681 | |
| 7200 |
돌아온깡통
|
11년 전 | 712 | |
| 7199 |
돌아온깡통
|
11년 전 | 1336 | |
| 7198 |
돌아온깡통
|
11년 전 | 664 | |
| 7197 |
돌아온깡통
|
11년 전 | 983 | |
| 7196 |
돌아온깡통
|
11년 전 | 889 | |
| 7195 |
돌아온깡통
|
11년 전 | 626 | |
| 7194 |
돌아온깡통
|
11년 전 | 654 | |
| 7193 |
돌아온깡통
|
11년 전 | 721 | |
| 7192 |
돌아온깡통
|
11년 전 | 750 | |
| 7191 |
joe031
|
11년 전 | 1280 | |
| 7190 | 11년 전 | 4167 | ||
| 7189 | 11년 전 | 1256 | ||
| 7188 |
잘살아보자
|
11년 전 | 975 | |
| 7187 | 11년 전 | 1453 | ||
| 7186 |
kiplayer
|
11년 전 | 7562 | |
| 7185 | 11년 전 | 1150 | ||
| 7184 |
잘살아보자
|
11년 전 | 2349 | |
| 7183 |
잘살아보자
|
11년 전 | 1166 | |
| 7182 |
잘살아보자
|
11년 전 | 1233 | |
| 7181 | 11년 전 | 1503 | ||
| 7180 |
하얀비요일
|
11년 전 | 999 | |
| 7179 |
잘살아보자
|
11년 전 | 1003 | |
| 7178 | 11년 전 | 998 | ||
| 7177 | 11년 전 | 1017 | ||
| 7176 | 11년 전 | 1670 | ||
| 7175 |
|
11년 전 | 1054 | |
| 7174 |
kiplayer
|
11년 전 | 1184 | |
| 7173 | 11년 전 | 965 | ||
| 7172 |
잘살아보자
|
11년 전 | 4650 | |
| 7171 |
잘살아보자
|
11년 전 | 717 | |
| 7170 | 11년 전 | 1083 | ||
| 7169 |
초심의설렘
|
11년 전 | 1482 | |
| 7168 | 11년 전 | 1019 | ||
| 7167 |
잘살아보자
|
11년 전 | 5299 | |
| 7166 |
잘살아보자
|
11년 전 | 3452 | |
| 7165 | 11년 전 | 4968 | ||
| 7164 | 11년 전 | 840 | ||
| 7163 | 11년 전 | 1218 | ||
| 7162 |
울라라라우
|
11년 전 | 1403 | |
| 7161 | 11년 전 | 1278 | ||
| 7160 |
skyler
|
11년 전 | 1195 | |
| 7159 |
|
11년 전 | 718 | |
| 7158 |
|
11년 전 | 3371 | |
| 7157 |
잘살아보자
|
11년 전 | 2903 | |
| 7156 |
잘살아보자
|
11년 전 | 2237 | |
| 7155 |
잘살아보자
|
11년 전 | 1466 | |
| 7154 |
잘살아보자
|
11년 전 | 1454 | |
| 7153 | 11년 전 | 2908 | ||
| 7152 |
울라라라우
|
11년 전 | 838 | |
| 7151 | 11년 전 | 1071 | ||
| 7150 |
잘살아보자
|
11년 전 | 2391 | |
| 7149 |
잘살아보자
|
11년 전 | 3306 | |
| 7148 |
잘살아보자
|
11년 전 | 1203 | |
| 7147 |
잘살아보자
|
11년 전 | 777 | |
| 7146 |
잘살아보자
|
11년 전 | 1419 | |
| 7145 |
잘살아보자
|
11년 전 | 735 | |
| 7144 |
잘살아보자
|
11년 전 | 1329 | |
| 7143 |
잘살아보자
|
11년 전 | 772 | |
| 7142 |
잘살아보자
|
11년 전 | 1461 | |
| 7141 |
잘살아보자
|
11년 전 | 1210 | |
| 7140 |
잘살아보자
|
11년 전 | 2026 | |
| 7139 |
잘살아보자
|
11년 전 | 3688 | |
| 7138 |
잘살아보자
|
11년 전 | 3186 | |
| 7137 |
잘살아보자
|
11년 전 | 3643 | |
| 7136 |
잘살아보자
|
11년 전 | 1398 | |
| 7135 |
gooroo
|
11년 전 | 1630 | |
| 7134 |
열라뽕똬이
|
11년 전 | 2331 | |
| 7133 |
|
11년 전 | 1028 | |
| 7132 | 11년 전 | 1444 | ||
| 7131 | 11년 전 | 3585 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기