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년 전
좋네요
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7530 | 10년 전 | 823 | ||
| 7529 |
파랑새1597
|
10년 전 | 1248 | |
| 7528 |
파랑새1597
|
10년 전 | 1335 | |
| 7527 |
integrity7
|
10년 전 | 1418 | |
| 7526 | 10년 전 | 2442 | ||
| 7525 |
다빈치코드777
|
10년 전 | 1125 | |
| 7524 | 10년 전 | 1593 | ||
| 7523 | 10년 전 | 980 | ||
| 7522 |
|
10년 전 | 1009 | |
| 7521 |
blackkil
|
10년 전 | 1896 | |
| 7520 | 10년 전 | 1314 | ||
| 7519 |
Gaumi
|
10년 전 | 1095 | |
| 7518 | 10년 전 | 1504 | ||
| 7517 | 10년 전 | 843 | ||
| 7516 | 10년 전 | 1311 | ||
| 7515 | 10년 전 | 1430 | ||
| 7514 |
|
10년 전 | 4500 | |
| 7513 |
멋진남자임
|
10년 전 | 1141 | |
| 7512 |
다빈치코드777
|
10년 전 | 895 | |
| 7511 |
|
10년 전 | 3418 | |
| 7510 | 10년 전 | 1383 | ||
| 7509 | 10년 전 | 1163 | ||
| 7508 | 10년 전 | 729 | ||
| 7507 |
senseme
|
10년 전 | 774 | |
| 7506 |
멋진남자임
|
10년 전 | 1666 | |
| 7505 | 10년 전 | 4044 | ||
| 7504 | 10년 전 | 2175 | ||
| 7503 | 10년 전 | 1010 | ||
| 7502 | 10년 전 | 534 | ||
| 7501 | 10년 전 | 1463 | ||
| 7500 | 10년 전 | 1509 | ||
| 7499 | 10년 전 | 3413 | ||
| 7498 | 10년 전 | 1260 | ||
| 7497 |
dethos79
|
10년 전 | 2980 | |
| 7496 | 10년 전 | 2197 | ||
| 7495 | 10년 전 | 921 | ||
| 7494 |
CHAVO
|
10년 전 | 1159 | |
| 7493 | 10년 전 | 2671 | ||
| 7492 | 10년 전 | 1304 | ||
| 7491 | 10년 전 | 1514 | ||
| 7490 | 10년 전 | 2364 | ||
| 7489 | 10년 전 | 2134 | ||
| 7488 |
toptopon
|
10년 전 | 918 | |
| 7487 |
|
10년 전 | 1061 | |
| 7486 | 10년 전 | 3376 | ||
| 7485 | 10년 전 | 1331 | ||
| 7484 | 10년 전 | 1386 | ||
| 7483 | 10년 전 | 1044 | ||
| 7482 | 10년 전 | 677 | ||
| 7481 | 10년 전 | 869 | ||
| 7480 | 10년 전 | 1251 | ||
| 7479 | 10년 전 | 2622 | ||
| 7478 | 10년 전 | 1186 | ||
| 7477 |
멋진남자임
|
10년 전 | 1535 | |
| 7476 |
zeppeto
|
10년 전 | 1151 | |
| 7475 |
200점아빠
|
10년 전 | 933 | |
| 7474 | 10년 전 | 4020 | ||
| 7473 | 10년 전 | 1008 | ||
| 7472 |
나르시스1
|
10년 전 | 1257 | |
| 7471 | 10년 전 | 889 | ||
| 7470 | 10년 전 | 1307 | ||
| 7469 |
플라이SINJI
|
10년 전 | 1018 | |
| 7468 |
|
10년 전 | 578 | |
| 7467 |
|
10년 전 | 698 | |
| 7466 | 10년 전 | 1152 | ||
| 7465 | 10년 전 | 1203 | ||
| 7464 |
|
10년 전 | 1216 | |
| 7463 | 10년 전 | 1278 | ||
| 7462 |
진짜별사탕
|
10년 전 | 881 | |
| 7461 | 10년 전 | 968 | ||
| 7460 | 10년 전 | 3761 | ||
| 7459 |
멋진남자임
|
10년 전 | 1578 | |
| 7458 |
멋진남자임
|
10년 전 | 505 | |
| 7457 | 10년 전 | 935 | ||
| 7456 | 10년 전 | 783 | ||
| 7455 | 10년 전 | 2194 | ||
| 7454 | 10년 전 | 646 | ||
| 7453 | 10년 전 | 854 | ||
| 7452 |
중국어사이트제작
|
11년 전 | 516 | |
| 7451 | 11년 전 | 925 | ||
| 7450 | 11년 전 | 648 | ||
| 7449 |
울라라라우
|
11년 전 | 967 | |
| 7448 | 11년 전 | 1642 | ||
| 7447 |
멋진남자임
|
11년 전 | 527 | |
| 7446 | 11년 전 | 570 | ||
| 7445 |
네이비칼라
|
11년 전 | 1708 | |
| 7444 |
senseme
|
11년 전 | 1425 | |
| 7443 | 11년 전 | 1353 | ||
| 7442 | 11년 전 | 746 | ||
| 7441 |
멋진남자임
|
11년 전 | 1457 | |
| 7440 | 11년 전 | 932 | ||
| 7439 |
|
11년 전 | 787 | |
| 7438 |
|
11년 전 | 957 | |
| 7437 |
basement
|
11년 전 | 1051 | |
| 7436 |
잘살아보자
|
11년 전 | 1147 | |
| 7435 | 11년 전 | 1107 | ||
| 7434 | 11년 전 | 3801 | ||
| 7433 |
|
11년 전 | 2772 | |
| 7432 |
alexkim
|
11년 전 | 877 | |
| 7431 |
이웃집초보
|
11년 전 | 1327 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기