简体   繁体   中英

on insert in textarea change other text

I like to change different content when insert text in texarea . Eg If I enter any text in the textarea the id=res and id=res2 should change to a static number. Means out of "-.-" should be "2.0" .

Thank you

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());
});

or see here: jsfiddle

You can use parseFloat function 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':'-.-');
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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