繁体   English   中英

在textarea中插入时更改其他文本

[英]on insert in textarea change other text

我喜欢在texarea插入文本时更改不同的内容。 例如,如果我在textarea输入任何文本,则id=resid=res2应该更改为静态数字。 表示"-.-"应为"2.0"

谢谢

HTML

<textarea id="inptxt" ></textarea>
<div id="res" >-.-</div>
<div id="res2">-.-</div>

JS

$("#inptxt").on("change input paste keyup", function() {
  $("#res").html(jQuery(this).val());
  $("#res2").html(jQuery(this).val());
});

或看这里: jsfiddle

您可以使用parseFloat函数http://jsfiddle.net/vineeshmp/ZVcG4/40/

$("#inptxt").on("change input paste keyup", function() {   
    $("#res").html(jQuery(this).val()?'2.0':'-.-');
    $("#res2").html(jQuery(this).val()?'2.0':'-.-');
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM