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

9th Sep 2021, 3:17 PM
Okafor Okwuchukwu Charisma
Okafor Okwuchukwu Charisma - avatar
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]; } }
9th Sep 2021, 3:29 PM
Abhay
Abhay - avatar
+ 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); }
9th Sep 2021, 3:29 PM
A͢J
A͢J - avatar
+ 2
tea.innerHTML=tea.textContent.slice(0,-10) https://code.sololearn.com/WtnMU6THVqT6/?ref=app
9th Sep 2021, 3:33 PM
SAN
SAN - avatar
+ 2
I love you all, thank you all for your contributions. I really appreciate your contributions. You made my day so wonderful.
9th Sep 2021, 5:38 PM
Okafor Okwuchukwu Charisma
Okafor Okwuchukwu Charisma - avatar
+ 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
9th Sep 2021, 6:15 PM
Okafor Okwuchukwu Charisma
Okafor Okwuchukwu Charisma - avatar
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.
9th Sep 2021, 5:53 PM
Okafor Okwuchukwu Charisma
Okafor Okwuchukwu Charisma - avatar