0
Pls I need help on how to delete an input in my "tea.innerHTML" using the "delete key".
Pls help me fix other problems on the css; like the <p> content steps outside the box. https://code.sololearn.com/WiqP42VED13z/?ref=app
6 odpowiedzi
+ 3
add "overflow-x:scroll" for p to make the content scrollable on x-axis instead of it going out of the box.
Why are you calling show() function in clr and del function ?
The calling of show in del without argument is the reason why you get undefined .
Change your code to following and it should work the way you want it to.
function show(val){
tea.innerHTML+=val;
}
function clr(){
tea.innerHTML="";
}
function del(){
let x = tea.innerHTML.toString();
tea.innerHTML="";
for(i=0;i<x.length-1;i++){
tea.innerHTML+= x[i];
}
}
+ 3
okafor okwuchukwu charisma
Do this to delete the last character in input box.
function del(){
let x = tea.innerHTML.toString();
tea.innerHTML = x.slice(0, -1);
}
+ 2
tea.innerHTML=tea.textContent.slice(0,-10)
https://code.sololearn.com/WtnMU6THVqT6/?ref=app
+ 2
I love you all, thank you all for your contributions. I really appreciate your contributions. You made my day so wonderful.
+ 1
@Abhay, please don't worry I now understand the reason. It has to be set,first, to undefined value and then update it with the result of the loop
0
@Abhay. Thank you once again, please tell me why (in del()) you have to set
tea.innerHTML="";
Because without that statement, the whole del() won't work as expected.