[英]jQuery .change doesn't work
為什么當我改變輸入時輸出沒有改變?
<div class="display" id="out">test</div>
<div class="form-group">
<label for="comment">value:</label>
<input class="form-control" type="text" value="0.00" id="in"></input>
</div>
$('#in').on("change", function(){
$('#out').html($(this).val());
});
您的小提琴中缺少 jQuery 庫。 使用input
或keyup
事件進行即時更新。 僅當您從輸入字段聚焦時才會觸發change
事件
$('#in').on("input", function(){ $('#out').html(this.value); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <div class="display" id="out">test</div> <div class="form-group"> <label for="comment">value:</label> <input class="form-control" type="text" value="0.00" id="in"/> </div>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.