Changing two attribute values using js

Changing two attribute values using js
0

#1

Hello!
Please, is there any help, I am trying to change tvo values using only one button, here is the code;

<!DOCTYPE html>
<html>
<body>

<h2>What Can JavaScript Do?</h2>



<ul>

<li id="demo">Java</li>
<li id="lala">PHP</li>
<li id="lili">C sharp </li>
</ul>

<button type="button" onclick="document.getElementById('lala').style.fontWeight = 'bold'">Bold</button>

<button type="button" onclick="document.getElementById('lala').style.color = 'red'">Red</button>

<button type="button" onclick="document.getElementById('lili').style.color = 'red'">Red</button>


</body>
</html>


Many thanks!

#2

What do you mean by changing two values?

Which two values? You have three buttons, which one button?


#3

Hello!
I want to use just one button to get one item bot bold AND red. Is that possible?


#4

Yes.

Remove your two other li elements. Leave the one you want to modify.
Remove all other buttons except the one you want to modify as well.

Target your li element with the correct id. After you execute one operation, chain another operation right after it whether it’s changing color or changing fontweight.


#5

Many thanks SOLVED!!!

:hugs::hugs::hugs::hugs: