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년 전
좋네요
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7830 | 10년 전 | 472 | ||
| 7829 |
|
10년 전 | 661 | |
| 7828 | 10년 전 | 584 | ||
| 7827 | 10년 전 | 484 | ||
| 7826 | 10년 전 | 504 | ||
| 7825 | 10년 전 | 544 | ||
| 7824 | 10년 전 | 497 | ||
| 7823 | 10년 전 | 435 | ||
| 7822 | 10년 전 | 409 | ||
| 7821 | 10년 전 | 361 | ||
| 7820 | 10년 전 | 371 | ||
| 7819 |
|
10년 전 | 773 | |
| 7818 | 10년 전 | 435 | ||
| 7817 | 10년 전 | 614 | ||
| 7816 | 10년 전 | 453 | ||
| 7815 | 10년 전 | 654 | ||
| 7814 | 10년 전 | 488 | ||
| 7813 | 10년 전 | 440 | ||
| 7812 | 10년 전 | 450 | ||
| 7811 | 10년 전 | 427 | ||
| 7810 | 10년 전 | 631 | ||
| 7809 | 10년 전 | 564 | ||
| 7808 | 10년 전 | 444 | ||
| 7807 | 10년 전 | 455 | ||
| 7806 |
프로그래머7
|
10년 전 | 1373 | |
| 7805 | 10년 전 | 1317 | ||
| 7804 |
zahir1312
|
10년 전 | 813 | |
| 7803 |
|
10년 전 | 1417 | |
| 7802 | 10년 전 | 518 | ||
| 7801 | 10년 전 | 894 | ||
| 7800 | 10년 전 | 1115 | ||
| 7799 | 10년 전 | 597 | ||
| 7798 | 10년 전 | 543 | ||
| 7797 | 10년 전 | 571 | ||
| 7796 | 10년 전 | 404 | ||
| 7795 | 10년 전 | 556 | ||
| 7794 | 10년 전 | 595 | ||
| 7793 | 10년 전 | 1097 | ||
| 7792 | 10년 전 | 525 | ||
| 7791 | 10년 전 | 616 | ||
| 7790 | 10년 전 | 550 | ||
| 7789 |
fbastore
|
10년 전 | 1498 | |
| 7788 | 10년 전 | 602 | ||
| 7787 | 10년 전 | 462 | ||
| 7786 | 10년 전 | 665 | ||
| 7785 | 10년 전 | 642 | ||
| 7784 | 10년 전 | 697 | ||
| 7783 | 10년 전 | 519 | ||
| 7782 | 10년 전 | 544 | ||
| 7781 | 10년 전 | 949 | ||
| 7780 | 10년 전 | 853 | ||
| 7779 | 10년 전 | 804 | ||
| 7778 | 10년 전 | 397 | ||
| 7777 | 10년 전 | 511 | ||
| 7776 | 10년 전 | 506 | ||
| 7775 | 10년 전 | 438 | ||
| 7774 | 10년 전 | 654 | ||
| 7773 | 10년 전 | 412 | ||
| 7772 | 10년 전 | 788 | ||
| 7771 | 10년 전 | 440 | ||
| 7770 | 10년 전 | 681 | ||
| 7769 | 10년 전 | 439 | ||
| 7768 | 10년 전 | 660 | ||
| 7767 | 10년 전 | 1214 | ||
| 7766 | 10년 전 | 546 | ||
| 7765 | 10년 전 | 607 | ||
| 7764 |
잘살아보자
|
10년 전 | 460 | |
| 7763 |
|
10년 전 | 1510 | |
| 7762 |
Tosea
|
10년 전 | 1093 | |
| 7761 | 10년 전 | 711 | ||
| 7760 |
잘살아보자
|
10년 전 | 777 | |
| 7759 |
잘살아보자
|
10년 전 | 616 | |
| 7758 |
잘살아보자
|
10년 전 | 678 | |
| 7757 | 10년 전 | 1304 | ||
| 7756 |
ITBANK
|
10년 전 | 1302 | |
| 7755 | 10년 전 | 1956 | ||
| 7754 | 10년 전 | 1111 | ||
| 7753 | 10년 전 | 930 | ||
| 7752 | 10년 전 | 1429 | ||
| 7751 |
잘살아보자
|
10년 전 | 592 | |
| 7750 |
잘살아보자
|
10년 전 | 525 | |
| 7749 |
잘살아보자
|
10년 전 | 549 | |
| 7748 |
잘살아보자
|
10년 전 | 571 | |
| 7747 |
잘살아보자
|
10년 전 | 645 | |
| 7746 |
잘살아보자
|
10년 전 | 708 | |
| 7745 |
잘살아보자
|
10년 전 | 955 | |
| 7744 |
잘살아보자
|
10년 전 | 448 | |
| 7743 | 10년 전 | 978 | ||
| 7742 |
starbros
|
10년 전 | 873 | |
| 7741 |
잘살아보자
|
10년 전 | 715 | |
| 7740 |
잘살아보자
|
10년 전 | 606 | |
| 7739 |
잘살아보자
|
10년 전 | 498 | |
| 7738 |
잘살아보자
|
10년 전 | 572 | |
| 7737 |
잘살아보자
|
10년 전 | 551 | |
| 7736 |
잘살아보자
|
10년 전 | 570 | |
| 7735 |
잘살아보자
|
10년 전 | 903 | |
| 7734 |
잘살아보자
|
10년 전 | 460 | |
| 7733 |
잘살아보자
|
10년 전 | 572 | |
| 7732 |
잘살아보자
|
10년 전 | 738 | |
| 7731 |
잘살아보자
|
10년 전 | 660 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기