【问题标题】:Get Text Area field value with reference to code using Jquery使用 Jquery 参考代码获取文本区域字段值
【发布时间】:2013-09-03 12:21:36
【问题描述】:

您好,我有以下代码示例,我想找出文本区域字段的值,

<span dir="none"><span dir="ltr">
<textarea name="ctl00$m$g_547673d5_a6d6_4c03_aa47_d9ad28312f65$ff161$ctl00$ctl00$TextField"
    rows="6" cols="20" id="ctl00_m_g_547673d5_a6d6_4c03_aa47_d9ad28312f65_ff161_ctl00_ctl00_TextField"
    title="Description" class="ms-long" dir="none"></textarea>
<input name="ctl00$m$g_547673d5_a6d6_4c03_aa47_d9ad28312f65$ff161$ctl00$ctl00$TextField_spSave"
    type="HIDDEN" id="ctl00_m_g_547673d5_a6d6_4c03_aa47_d9ad28312f65_ff161_ctl00_ctl00_TextField_spSave">

我试过了 var test = $('textarea[Title="Description"]').val(); 和 var test=$(#ID).val();

所以请帮助我。 谢谢, 二甘巴K

【问题讨论】:

  • 使用 Jquery 还是 javascript?

标签: jquery


【解决方案1】:

如果您使用的是 asp.net 和 jquery,看起来您使用的是 asp.net

使用

var textareaValue=$('#<%=textareaelementId.ClientId%>').val();

【讨论】:

    【解决方案2】:

    使用

         var thought = $('textarea[name=ctl00$m$g_547673d5_a6d6_4c03_aa47_d9ad28312f65$ff161$ctl00$ctl00$TextField]').val();
    

         var thought = $('#ctl00_m_g_547673d5_a6d6_4c03_aa47_d9ad28312f65_ff161_ctl00_ctl00_TextField').val();
    

    【讨论】:

      【解决方案3】:

      试试这个

      $(function(){
          $("#ctl00_m_g_547673d5_a6d6_4c03_aa47_d9ad28312f65_ff161_ctl00_ctl00_TextField").change(function(){ 
            alert($("#ctl00_m_g_547673d5_a6d6_4c03_aa47_d9ad28312f65_ff161_ctl00_ctl00_TextField").val());
      
          });
      });
      

      Demo

      【讨论】:

      • 我想在表单预存中获取价值。
      • 在保存时使用 if($("#ctl00_m_g_547673d5_a6d6_4c03_aa47_d9ad28312f65_ff161_ctl00_ctl00_TextField").val()=="") {alert("请输入值。");return false;}
      猜你喜欢
      • 2018-09-26
      • 1970-01-01
      • 2012-07-21
      • 2019-11-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多