Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm developing a virtual Turkish alphabet keyboard. I'm trying to replace "ed" with "??", it works well however it shows "ed" before replacing. How can I get rid off that ? Note that if your computer doesn't have Unicode 6 or more it won't show you the special character which is a skinny X.

$('#text').keyup(function(e) {
  $('#text').css('direction', 'rtl');
  $('#text').css('unicode-bidi', 'bidi-override');
  text2 = $(this).val();
  text2 = text2.replace(/(ed)/g, "??");
  $("#text").val(text2);
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<textarea id="text"></textarea>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
308 views
Welcome To Ask or Share your Answers For Others

1 Answer

Use input event instead.

$('#text').on('input', function(e) {
  $('#text').css('direction', 'rtl');
  $('#text').css('unicode-bidi', 'bidi-override');
  text2 = $(this).val();
  text2 = text2.replace(/(ed)/g, "??");
  $("#text").val(text2);
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<textarea id="text"></textarea>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...