0

データリストに入力があります

<input type="text" value="1" id="txtcount">

テキストが変更されたときに新しい値を取得したい。

このコードを使用していますが、うまくいきません。

<script>
//look no global needed:)

$(document).ready(function(){
    // Get the initial value
   var $el = $('#txtcount');
   $el.data('oldVal',  $el.val() );


   $el.change(function(){
        //store new value
        var $this = $(this);
        var newValue = $this.data('newVal', $this.val());
   })
   .focus(function(){
        // Get the value when input gains focus
        var oldValue = $(this).data('oldVal');
   });
});

4

2 に答える 2

0

これを使って :-

$('#txtcount').keyup(function(event) {
  if (event.keyCode == 13) {
    var message =  $('#txtcount').val();
    alert(message);
  } else {
    return true;
  }
});

または、TextField の「onTextChanged」イベントで値を取得できます。

于 2012-05-15T06:16:09.370 に答える