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년 전
좋네요
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 5930 | 13년 전 | 4643 | ||
| 5929 | 13년 전 | 7841 | ||
| 5928 | 13년 전 | 792 | ||
| 5927 | 13년 전 | 1419 | ||
| 5926 | 13년 전 | 1838 | ||
| 5925 |
김준수사랑
|
13년 전 | 1252 | |
| 5924 |
|
13년 전 | 2762 | |
| 5923 | 13년 전 | 962 | ||
| 5922 | 13년 전 | 1170 | ||
| 5921 | 13년 전 | 659 | ||
| 5920 | 13년 전 | 1182 | ||
| 5919 |
|
13년 전 | 1377 | |
| 5918 | 13년 전 | 12592 | ||
| 5917 |
프로프리랜서
|
13년 전 | 1100 | |
| 5916 |
프로프리랜서
|
13년 전 | 4632 | |
| 5915 |
프로프리랜서
|
13년 전 | 1609 | |
| 5914 |
프로프리랜서
|
13년 전 | 654 | |
| 5913 |
프로프리랜서
|
13년 전 | 938 | |
| 5912 |
프로프리랜서
|
13년 전 | 3748 | |
| 5911 |
프로프리랜서
|
13년 전 | 929 | |
| 5910 |
|
13년 전 | 4588 | |
| 5909 |
수야3019
|
13년 전 | 675 | |
| 5908 | 13년 전 | 836 | ||
| 5907 | 13년 전 | 1234 | ||
| 5906 | 13년 전 | 8757 | ||
| 5905 |
프로프리랜서
|
13년 전 | 1475 | |
| 5904 | 13년 전 | 2498 | ||
| 5903 | 13년 전 | 1652 | ||
| 5902 | 13년 전 | 1929 | ||
| 5901 | 13년 전 | 2020 | ||
| 5900 |
프로프리랜서
|
13년 전 | 1092 | |
| 5899 |
프로프리랜서
|
13년 전 | 1282 | |
| 5898 | 13년 전 | 17679 | ||
| 5897 | 13년 전 | 2337 | ||
| 5896 | 13년 전 | 4363 | ||
| 5895 | 13년 전 | 1692 | ||
| 5894 | 13년 전 | 2103 | ||
| 5893 |
프로프리랜서
|
13년 전 | 2162 | |
| 5892 | 13년 전 | 16041 | ||
| 5891 |
bitmaster
|
13년 전 | 1083 | |
| 5890 |
프로프리랜서
|
13년 전 | 947 | |
| 5889 |
|
13년 전 | 726 | |
| 5888 | 13년 전 | 1619 | ||
| 5887 |
|
13년 전 | 3200 | |
| 5886 | 13년 전 | 3449 | ||
| 5885 | 13년 전 | 2110 | ||
| 5884 | 13년 전 | 5655 | ||
| 5883 | 13년 전 | 2822 | ||
| 5882 | 13년 전 | 6031 | ||
| 5881 | 13년 전 | 1640 | ||
| 5880 | 13년 전 | 20721 | ||
| 5879 | 13년 전 | 912 | ||
| 5878 |
나의라임토마토
|
13년 전 | 1412 | |
| 5877 | 13년 전 | 16778 | ||
| 5876 |
maniAc
|
13년 전 | 2810 | |
| 5875 | 13년 전 | 1039 | ||
| 5874 | 13년 전 | 3736 | ||
| 5873 |
lainfox
|
13년 전 | 1186 | |
| 5872 | 13년 전 | 1350 | ||
| 5871 | 13년 전 | 798 | ||
| 5870 | 13년 전 | 2529 | ||
| 5869 |
AMDbest
|
13년 전 | 1514 | |
| 5868 |
한번잘해보자
|
13년 전 | 664 | |
| 5867 |
|
13년 전 | 921 | |
| 5866 | 13년 전 | 7494 | ||
| 5865 | 13년 전 | 2411 | ||
| 5864 | 13년 전 | 940 | ||
| 5863 | 13년 전 | 1311 | ||
| 5862 | 13년 전 | 2878 | ||
| 5861 | 13년 전 | 1032 | ||
| 5860 | 13년 전 | 19333 | ||
| 5859 | 13년 전 | 2946 | ||
| 5858 | 13년 전 | 2654 | ||
| 5857 | 13년 전 | 4830 | ||
| 5856 |
|
13년 전 | 1954 | |
| 5855 | 13년 전 | 822 | ||
| 5854 | 13년 전 | 1010 | ||
| 5853 | 13년 전 | 16111 | ||
| 5852 | 13년 전 | 826 | ||
| 5851 | 13년 전 | 2223 | ||
| 5850 | 13년 전 | 1775 | ||
| 5849 |
AMDbest
|
13년 전 | 1309 | |
| 5848 |
|
13년 전 | 1166 | |
| 5847 |
SeanLee
|
13년 전 | 1309 | |
| 5846 | 13년 전 | 23472 | ||
| 5845 | 13년 전 | 2656 | ||
| 5844 | 13년 전 | 28814 | ||
| 5843 |
|
13년 전 | 2210 | |
| 5842 | 13년 전 | 22528 | ||
| 5841 | 13년 전 | 5748 | ||
| 5840 |
Quincy
|
13년 전 | 937 | |
| 5839 | 13년 전 | 968 | ||
| 5838 | 13년 전 | 2822 | ||
| 5837 | 13년 전 | 1100 | ||
| 5836 | 13년 전 | 2321 | ||
| 5835 | 13년 전 | 1523 | ||
| 5834 | 13년 전 | 1507 | ||
| 5833 | 13년 전 | 6680 | ||
| 5832 | 13년 전 | 5214 | ||
| 5831 | 13년 전 | 1072 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기