Answer the question
In order to leave comments, you need to log in
How to make printing in uppercase only the letter "a"?
Hi friends, there is a problem, I’m just learning in js, so I don’t know banal things ...
there is an input, I enter text into it, and I need the entered text to be displayed immediately in the div below (I sort of figured it out) But you need to if the letter a got into the input, then it was transferred to the div in upper case, can you help?)
function my_keyup() {
txt = document.getElementById('value_for_div3').value;
document.getElementById("div3").innerHTML = txt;
}
//Напечатан символ
function my_keypress($event)
{
//Код клавиши
var x = ($event.keyCode || $event.which);
var x_char = String.fromCharCode(x);
//Если буква а(русская)
if (x_char=='а') {
}
}
Answer the question
In order to leave comments, you need to log in
There is an easier way:
var div = document.getElementById("div3");
var input = document.getElementById('value_for_div3');
input.addEventListener('keyup', function(e) {
div.innerHTML = this.value.replace(/а/g, 'A');
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question