+ 4
Web developer How to make button to delete letter in this code?
In this code when I click on any button a letter is write in text area how to make button to delete this letter? https://code.sololearn.com/WTULRuz9d6Me/?ref=app
8 odpowiedzi
+ 15
Maybe the problem is the name of function, the code of @Ashwani works well with me, in short... you have to replace the name of function, @Ashwani has setted the name in "deleteChar()", you have to set the name in "text()" and replace your text() function.
As @Abdel said, his code reset the text and doesn't work for delete a single character, use the function of @Ashwani but change the name of the function.
Bye.
+ 9
You can use below function on click of delete button.
function deleteChar(){
var text = document.getElementById("my")
.innerHTML.toString();
document.getElementById("my")
.innerHTML = text.slice(0, text.length-1);
}
+ 8
If you want character by character deletion of the present text in the text area, then this is the code and works fine.
If your requirement is something else, then you can explain further.
+ 5
I try it but it is wrong
+ 5
Yeah , when I used @Ashwani code I changed the function name to text() as @Maz said
tip: @Kirollos Ayman
your javascript didn't went alright, don't forget to look at the console
GOOD LUCK
+ 5
thanks very much for your answer
+ 4
Hey @Kirollos
I have edited the last function and the last button
It works.
but the above code from @Askhwani is the best
because mine resets everything and that's not cool
GOOD LUCK
function text(){
document.getElementById("my").innerHTML = '';
}
<button onclick="text()">Delete</button>
+ 2
which one @Kirollos ?