Javascript & JQuery & CSS > Jquery Selector - selectbox ¿¹Á¦. µî·ÏÀÏ : 2017-07-04 21:48 Á¶È¸¼ö : 57,248jQuery - selectbox - ¼±ÅÃµÈ value °ª
jQuery - selectbox - ¼±ÅÃµÈ Text °ª $("#selectBox option:selected").text(); jQuery - selectbox - ¼±ÅÃµÈ À§Ä¡ ã±â(index) var index = $("#test option").index($("#test option:selected")); JQuery - selectbox - option Ãß°¡ //option Ãß°¡ - ¸¶Áö¸· $("#selectBox").append("<option value="ÈÀÌÆ®">ÈÀÌÆ®</option>"); $("#selectBox").append("<option value="±×¸°">±×¸°</option>"); $("#selectBox").append("<option value="ºí·¢">ºí·¢</option>"); //option Ãß°¡ - óÀ½ $("#selectBox").prepend("<option value="ºí·¢">ºí·¢</option>"); //option Ãß°¡ - 0¹ø° item ´ÙÀ½¿¡ »ðÀÔ $("#selectBox option:eq(0)").after("Some pears"); //option Ãß°¡ - 3¹ø° item Àü¿¡ »ðÀÔ $("#selectBox option:eq(3)").before("Some apricots"); jQuery - selectbox - option »èÁ¦ // ¸ðµç item »èÁ¦ $("#selectBox").children('option').remove(); // ÁöÁ¤µÈ À妽º °ªÀÇ item »èÁ¦ $("#selectBox option:eq(0)").remove(); // ù¹ø° itemÀ» »©°í ³ª¸ÓÁö »èÁ¦ $("#selectBox option:not(:first)").remove(); // ù¹ø° item »èÁ¦ $("#selectBox option:first").remove(); // ¸¶Áö¸· item »èÁ¦ $("#selectBox option:last").remove(); jQuery - selectbox - »õ·Î¿î option »ý¼º $("#selectBox").html("<option value="111">111</option><option value="222">222"); jQuery - selectbox - option º¯°æ //2¹ø° À妽º°ªÀÇ option º¯°æ $("#selectbox option:eq(1)").replaceWith("<option value="2¹ø°">2¹ø°"); jQuery - selectbox - selected ¹æ¹ý //ÁöÁ¤µÈ index °ªÀ¸·Î selected Çϱâ $("#selectBox option:eq(2)").attr("selected", "selected"); // value °ªÀ¸·Î selected Çϱâ $("#selectBox").val("Some oranges").attr("selected", "selected"); $("#selectBox > option[@value=ÁöÁ¤°ª]").attr("selected", "true"); $("#selectBox").val("2"); jQuery - selectbox - option °¹¼ö // SelecBox ¾ÆÀÌÅÛ °¹¼ö ±¸Çϱâ $("#selectBox option").size(); // ¼±ÅÃµÈ ¿É¼Ç ¾ÕÀÇ ¾ÆÀÌÅÛ °¹¼ö $("#selectBox option:selected").prevAll().size(); // ¼±ÅÃµÈ ¿É¼Ç ÈÄÀÇ ¾ÆÀÌÅÛ °¹¼ö $("#selectBox option:selected").nextAll().size(); jQuery - selectbox disabled ¼Ó¼º Àû¿ë $('#select_box').attr('disabled', 'true'); jQuery - select box °ªÀÌ º¯°æµÉ¶§ ¼±ÅÃµÈ ÇöÀç°ª $("#selectBox").change(function() { this_value = $(this).val(); this_txt = $(this).children("option:selected").text(); }); Javascript - selectbox option Ãß°¡ var selectbox = document.getElementById("j_selectbox"); selectbox.options[1] = new Option("textÃß°¡1","text1"); selectbox.options[2] = new Option("textÃß°¡2","text2"); selectbox.options[3] = new Option("textÃß°¡3","text3"); javascript - selectbox ¼±ÅÃµÈ index °ª selectbox = document.getElementById('j_selectbox'); idx = selectbox.selectedIndex; Javascript -selectbox ƯÁ¤À§Ä¡ selected selectbox = document.getElementById('j_selectbox'); selectbox[5].selected = true; Javascript -selectbox - option ±æÀÌ selectbox = document.getElementById('j_selectbox'); len = selectbox .length; Javascript - selectbox - ¼±ÅÃµÈ value/text ±¸Çϱâ var selectbox = document.getElementById("j_selectbox"); idx = selectbox.selectedIndex; val = selectbox.item(idx).value; txt = selectbox.item(idx).text; ¶Ç´Â val = selectbox.options[idx].value; txt = selectbox.options[idx].text; val = selectbox.value; Javascript - selectbox - disabled Àû¿ë selectbox.disabled = true; selectbox.disabled = false;
|