简体   繁体   English

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

[英]on insert in textarea change other text

I like to change different content when insert text in texarea . 我喜欢在texarea插入文本时更改不同的内容。 Eg If I enter any text in the textarea the id=res and id=res2 should change to a static number. 例如,如果我在textarea输入任何文本,则id=resid=res2应该更改为静态数字。 Means out of "-.-" should be "2.0" . 表示"-.-"应为"2.0"

Thank you 谢谢

html HTML

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

js JS

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

or see here: jsfiddle 或看这里: jsfiddle

You can use parseFloat function http://jsfiddle.net/vineeshmp/ZVcG4/40/ 您可以使用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