0

How to make it? When i click the underline it will underline the word.

https://code.sololearn.com/Wb6obmJ5ZTTz/?ref=app

29th Sep 2020, 12:55 PM
Kyrene
13 Answers
29th Sep 2020, 3:08 PM
Divya Mohan
Divya Mohan - avatar
+ 5
Oh it was not working when clicked very first You can do it as function Underline() { var u = document.getElementById("txt").value; document.getElementById("t").innerHTML = u ; document.getElementById("t").style.textDecoration = "underline "; }
29th Sep 2020, 1:39 PM
Divya Mohan
Divya Mohan - avatar
+ 3
See if want to show only those effect which is button for, You can add additional action to the function. Like when click highlight remove bold,italic,underline,strike It will show you only that effect.so you can try that also To remove all effect first and then apply the mentioned one.
29th Sep 2020, 2:11 PM
Divya Mohan
Divya Mohan - avatar
+ 2
I think underline is working good Explain it if any.... You xan set placeholder instead of value for input.
29th Sep 2020, 1:24 PM
Divya Mohan
Divya Mohan - avatar
+ 2
You can have a variable holding the element of ID "t". Then have the variable do style.textDecoration("underline") and assign u to its innerHTML. Like: var z = document.getElementById("t"); z.style.textDecoration = "underline"; z.innerHTML = u;
29th Sep 2020, 1:35 PM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 2
Sorry if you don't know classlist 's method in js I have used that https://code.sololearn.com/W3CeBGeKBtSt/?ref=app
29th Sep 2020, 3:01 PM
Divya Mohan
Divya Mohan - avatar
+ 1
Ok,thank you so much ❤️
29th Sep 2020, 1:45 PM
Kyrene
+ 1
For highlight also can use this method?
29th Sep 2020, 2:01 PM
Kyrene
+ 1
function Highlight() { var h = document.getElementById("txt").value; document.getElementById("t").style.backgroundColor = "yellow"; document.getElementById("t").innerHTML = h ; }
29th Sep 2020, 2:02 PM
Kyrene
+ 1
Thanks. Because i google the remove method got many type. This help me a lot!
29th Sep 2020, 3:05 PM
Kyrene
0
Because when i use this method it can work but when i click highlight button first then click the underline button it will show out underline and highlight
29th Sep 2020, 2:05 PM
Kyrene
0
Can give me some example?
29th Sep 2020, 2:12 PM
Kyrene
0
Ok ❤️
29th Sep 2020, 3:12 PM
Kyrene