如何在jquery中使用下拉列表插入textarea内容

时间:2012-08-23 13:35:38

标签: javascript jquery html

我是jquery的新手并且有问题......可能你可以帮忙...

<select name="prodName[]" class="select-head" id="prodName0">
  <option value="">Select Product</option>
  <option value="add_prod">Add New</option>
 <-- Here i have db select query --><option value=" "></option></select>

我的jquery为

 $(".select-head").live('change',function() { 
      if($(this).val() != "") { 
          $(this).next().val($(this).val()); 
      }
  });

2 个答案:

答案 0 :(得分:1)

 $(".select-head").on('change',function () { 
     var selText = $(this).find('option:selected').text(); //.val() for value
     $('.textarea').val(selText);           
 });

答案 1 :(得分:0)

 $(".select-head").live('change',function () {
       if($(this).val() == "add_prod") { 
          var price=$(this).find('option:selected').attr('role');
          $(this).parent().parent().find('#num').val(price);
       }
  }