{"id":3165,"date":"2014-01-09T15:22:47","date_gmt":"2014-01-09T06:22:47","guid":{"rendered":"http:\/\/auctionpro.co.kr\/?p=3165"},"modified":"2019-06-05T17:29:11","modified_gmt":"2019-06-05T08:29:11","slug":"jquery-%ec%bd%a4%eb%b3%b4%eb%b0%95%ec%8a%a4-select-%ec%a0%9c%ec%96%b4","status":"publish","type":"post","link":"https:\/\/www.auctionpro.co.kr\/?p=3165","title":{"rendered":"jQuery \ucf64\ubcf4\ubc15\uc2a4  select \uc81c\uc5b4"},"content":{"rendered":"\n<pre class=\"lang:js decode:true \" >jQuery\ub85c \uc120\ud0dd\ub41c \uac12 \uc77d\uae30\r\n$(\"#selectBox option:selected\").val();\r\n$(\"select[name=name]\").val();\r\n \r\njQuery\ub85c \uc120\ud0dd\ub41c \ub0b4\uc6a9 \uc77d\uae30\r\n$(\"#selectBox option:selected\").text();\r\n \r\n\uc120\ud0dd\ub41c \uc704\uce58\r\nvar index = $(\"#test option\").index($(\"#test option:selected\"));\r\n \r\n-------------------------------------------------------------------\r\n \r\n\/\/ Add options to the end of a select\r\n$(\"#selectBox\").append(\"&lt;option value='1'&gt;Apples&lt;\/option&gt;\");\r\n$(\"#selectBox\").append(\"&lt;option value='2'&gt;After Apples&lt;\/option&gt;\");\r\n \r\n\/\/ Add options to the start of a select\r\n$(\"#selectBox\").prepend(\"&lt;option value='0'&gt;Before Apples&lt;\/option&gt;\");\r\n \r\n\/\/ Replace all the options with new options\r\n$(\"#selectBox\").html(\"&lt;option value='1'&gt;Some oranges&lt;\/option&gt;&lt;option value='2'&gt;More Oranges&lt;\/option&gt;\");\r\n \r\n\/\/ Replace items at a certain index\r\n$(\"#selectBox option:eq(1)\").replaceWith(\"&lt;option value='2'&gt;Some apples&lt;\/option&gt;\");\r\n$(\"#selectBox option:eq(2)\").replaceWith(\"&lt;option value='3'&gt;Some bananas&lt;\/option&gt;\");\r\n \r\n\/\/ \uc9c0\uc815\ub41c index \uac12\uc73c\ub85c select \ud558\uae30\r\n$(\"#selectBox option:eq(2)\").attr(\"selected\", \"selected\");\r\n \r\n\/\/ text \uac12\uc73c\ub85c select \ud558\uae30\r\n$(\"#selectBox\").val(\"Some oranges\").attr(\"selected\", \"selected\");\r\n \r\n\/\/ value \uac12\uc73c\ub85c select \ud558\uae30\r\n$(\"#selectBox\").val(\"2\");\r\n \r\n\/\/ \uc9c0\uc815\ub41c \uc778\ub371\uc2a4 \uac12\uc758 item \uc0ad\uc81c\r\n$(\"#selectBox option:eq(0)\").remove();\r\n \r\n\/\/ \uccab\ubc88\uc9f8 item \uc0ad\uc81c\r\n$(\"#selectBox option:first\").remove();\r\n \r\n\/\/ \ub9c8\uc9c0\ub9c9 item \uc0ad\uc81c\r\n$(\"#selectBox option:last\").remove();\r\n \r\n\/\/ \uc120\ud0dd\ub41c \uc635\uc158\uc758 text \uad6c\ud558\uae30\r\nalert($(\"#selectBox option:selected\").text());\r\n \r\n\/\/ \uc120\ud0dd\ub41c \uc635\uc158\uc758 value \uad6c\ud558\uae30\r\nalert($(\"#selectBox option:selected\").val());\r\n \r\n\/\/ \uc120\ud0dd\ub41c \uc635\uc158 index \uad6c\ud558\uae30\r\nalert($(\"#selectBox option\").index($(\"#selectBox option:selected\")));\r\n \r\n\/\/ SelecBox \uc544\uc774\ud15c \uac2f\uc218 \uad6c\ud558\uae30\r\nalert($(\"#selectBox option\").size());\r\n \r\n\/\/ \uc120\ud0dd\ub41c \uc635\uc158 \uc55e\uc758 \uc544\uc774\ud15c \uac2f\uc218\r\nalert($(\"#selectBox option:selected\").prevAll().size());\r\n \r\n\/\/ \uc120\ud0dd\ub41c \uc635\uc158 \ud6c4\uc758 \uc544\uc774\ud15c \uac2f\uc218\r\nalert($(\"#selectBox option:selected\").nextAll().size());\r\n \r\n\/\/ Insert an item in after a particular position\r\n$(\"#selectBox option:eq(0)\").after(\"&lt;option value='4'&gt;Some pears&lt;\/option&gt;\");\r\n \r\n\/\/ Insert an item in before a particular position\r\n$(\"#selectBox option:eq(3)\").before(\"&lt;option value='5'&gt;Some apricots&lt;\/option&gt;\");\r\n \r\n\/\/ Getting values when item is selected\r\n$(\"#selectBox\").change(function() {\r\n           alert($(this).val());\r\n           alert($(this).children(\"option:selected\").text());\r\n});\r\n[\ucd9c\ucc98] jQuery \ucf64\ubcf4 select \uc81c\uc5b4\ud558\uae30|\uc791\uc131\uc790 \uc5f4\ub9b0\ubb38\uc11c\r\n \uc0ad\uc81c\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>jQuery\ub85c \uc120\ud0dd\ub41c \uac12 \uc77d\uae30 $(&#8220;#selectBox option:selected&#8221;).val(); $(&#8220;select[name=name]&#8221;).val(); jQuery\ub85c \uc120\ud0dd\ub41c \ub0b4\uc6a9 \uc77d\uae30 $(&#8220;#selectBox option:selected&#8221;).text(); \uc120\ud0dd\ub41c \uc704\uce58 var index = $(&#8220;#test option&#8221;).index($(&#8220;#test option:selected&#8221;)); &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- \/\/ Add options <a class=\"mh-excerpt-more\" href=\"https:\/\/www.auctionpro.co.kr\/?p=3165\" title=\"jQuery \ucf64\ubcf4\ubc15\uc2a4  select \uc81c\uc5b4\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[8],"tags":[],"class_list":["post-3165","post","type-post","status-publish","format-standard","hentry","category-jquery"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>jQuery \ucf64\ubcf4\ubc15\uc2a4 select \uc81c\uc5b4 - AuctionPro<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.auctionpro.co.kr\/?p=3165\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"jQuery \ucf64\ubcf4\ubc15\uc2a4 select \uc81c\uc5b4 - AuctionPro\" \/>\n<meta property=\"og:description\" content=\"jQuery\ub85c \uc120\ud0dd\ub41c \uac12 \uc77d\uae30 $(&quot;#selectBox option:selected&quot;).val(); $(&quot;select[name=name]&quot;).val(); jQuery\ub85c \uc120\ud0dd\ub41c \ub0b4\uc6a9 \uc77d\uae30 $(&quot;#selectBox option:selected&quot;).text(); \uc120\ud0dd\ub41c \uc704\uce58 var index = $(&quot;#test option&quot;).index($(&quot;#test option:selected&quot;)); ------------------------------------------------------------------- \/\/ Add options [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.auctionpro.co.kr\/?p=3165\" \/>\n<meta property=\"og:site_name\" content=\"AuctionPro\" \/>\n<meta property=\"article:published_time\" content=\"2014-01-09T06:22:47+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-06-05T08:29:11+00:00\" \/>\n<meta name=\"author\" content=\"golgol\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\uae00\uc4f4\uc774\" \/>\n\t<meta name=\"twitter:data1\" content=\"golgol\" \/>\n\t<meta name=\"twitter:label2\" content=\"\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04\" \/>\n\t<meta name=\"twitter:data2\" content=\"1\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.auctionpro.co.kr\\\/?p=3165#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.auctionpro.co.kr\\\/?p=3165\"},\"author\":{\"name\":\"golgol\",\"@id\":\"https:\\\/\\\/www.auctionpro.co.kr\\\/#\\\/schema\\\/person\\\/d3dbae599b06cd55f5b14a3e2116f7a2\"},\"headline\":\"jQuery \ucf64\ubcf4\ubc15\uc2a4 select \uc81c\uc5b4\",\"datePublished\":\"2014-01-09T06:22:47+00:00\",\"dateModified\":\"2019-06-05T08:29:11+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.auctionpro.co.kr\\\/?p=3165\"},\"wordCount\":2,\"commentCount\":0,\"articleSection\":[\"[Dev]JQuery\"],\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.auctionpro.co.kr\\\/?p=3165#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.auctionpro.co.kr\\\/?p=3165\",\"url\":\"https:\\\/\\\/www.auctionpro.co.kr\\\/?p=3165\",\"name\":\"jQuery \ucf64\ubcf4\ubc15\uc2a4 select \uc81c\uc5b4 - AuctionPro\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.auctionpro.co.kr\\\/#website\"},\"datePublished\":\"2014-01-09T06:22:47+00:00\",\"dateModified\":\"2019-06-05T08:29:11+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.auctionpro.co.kr\\\/#\\\/schema\\\/person\\\/d3dbae599b06cd55f5b14a3e2116f7a2\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.auctionpro.co.kr\\\/?p=3165#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.auctionpro.co.kr\\\/?p=3165\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.auctionpro.co.kr\\\/?p=3165#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\\\/\\\/www.auctionpro.co.kr\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"jQuery \ucf64\ubcf4\ubc15\uc2a4 select \uc81c\uc5b4\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.auctionpro.co.kr\\\/#website\",\"url\":\"https:\\\/\\\/www.auctionpro.co.kr\\\/\",\"name\":\"AuctionPro\",\"description\":\"\uc625\uc158\ud504\ub85c\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.auctionpro.co.kr\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.auctionpro.co.kr\\\/#\\\/schema\\\/person\\\/d3dbae599b06cd55f5b14a3e2116f7a2\",\"name\":\"golgol\",\"url\":\"https:\\\/\\\/www.auctionpro.co.kr\\\/?author=6\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"jQuery \ucf64\ubcf4\ubc15\uc2a4 select \uc81c\uc5b4 - AuctionPro","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.auctionpro.co.kr\/?p=3165","og_locale":"ko_KR","og_type":"article","og_title":"jQuery \ucf64\ubcf4\ubc15\uc2a4 select \uc81c\uc5b4 - AuctionPro","og_description":"jQuery\ub85c \uc120\ud0dd\ub41c \uac12 \uc77d\uae30 $(\"#selectBox option:selected\").val(); $(\"select[name=name]\").val(); jQuery\ub85c \uc120\ud0dd\ub41c \ub0b4\uc6a9 \uc77d\uae30 $(\"#selectBox option:selected\").text(); \uc120\ud0dd\ub41c \uc704\uce58 var index = $(\"#test option\").index($(\"#test option:selected\")); ------------------------------------------------------------------- \/\/ Add options [...]","og_url":"https:\/\/www.auctionpro.co.kr\/?p=3165","og_site_name":"AuctionPro","article_published_time":"2014-01-09T06:22:47+00:00","article_modified_time":"2019-06-05T08:29:11+00:00","author":"golgol","twitter_card":"summary_large_image","twitter_misc":{"\uae00\uc4f4\uc774":"golgol","\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04":"1\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.auctionpro.co.kr\/?p=3165#article","isPartOf":{"@id":"https:\/\/www.auctionpro.co.kr\/?p=3165"},"author":{"name":"golgol","@id":"https:\/\/www.auctionpro.co.kr\/#\/schema\/person\/d3dbae599b06cd55f5b14a3e2116f7a2"},"headline":"jQuery \ucf64\ubcf4\ubc15\uc2a4 select \uc81c\uc5b4","datePublished":"2014-01-09T06:22:47+00:00","dateModified":"2019-06-05T08:29:11+00:00","mainEntityOfPage":{"@id":"https:\/\/www.auctionpro.co.kr\/?p=3165"},"wordCount":2,"commentCount":0,"articleSection":["[Dev]JQuery"],"inLanguage":"ko-KR","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.auctionpro.co.kr\/?p=3165#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.auctionpro.co.kr\/?p=3165","url":"https:\/\/www.auctionpro.co.kr\/?p=3165","name":"jQuery \ucf64\ubcf4\ubc15\uc2a4 select \uc81c\uc5b4 - AuctionPro","isPartOf":{"@id":"https:\/\/www.auctionpro.co.kr\/#website"},"datePublished":"2014-01-09T06:22:47+00:00","dateModified":"2019-06-05T08:29:11+00:00","author":{"@id":"https:\/\/www.auctionpro.co.kr\/#\/schema\/person\/d3dbae599b06cd55f5b14a3e2116f7a2"},"breadcrumb":{"@id":"https:\/\/www.auctionpro.co.kr\/?p=3165#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.auctionpro.co.kr\/?p=3165"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.auctionpro.co.kr\/?p=3165#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/www.auctionpro.co.kr\/"},{"@type":"ListItem","position":2,"name":"jQuery \ucf64\ubcf4\ubc15\uc2a4 select \uc81c\uc5b4"}]},{"@type":"WebSite","@id":"https:\/\/www.auctionpro.co.kr\/#website","url":"https:\/\/www.auctionpro.co.kr\/","name":"AuctionPro","description":"\uc625\uc158\ud504\ub85c","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.auctionpro.co.kr\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Person","@id":"https:\/\/www.auctionpro.co.kr\/#\/schema\/person\/d3dbae599b06cd55f5b14a3e2116f7a2","name":"golgol","url":"https:\/\/www.auctionpro.co.kr\/?author=6"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.auctionpro.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/3165","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.auctionpro.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.auctionpro.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.auctionpro.co.kr\/index.php?rest_route=\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/www.auctionpro.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3165"}],"version-history":[{"count":0,"href":"https:\/\/www.auctionpro.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/3165\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.auctionpro.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3165"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.auctionpro.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3165"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.auctionpro.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3165"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}