0

Can someone please tell me why css background color is not working

I have to use inline css background color to make this code run. So why it's not working with external css. It' is keep throwing error that style property is null. https://code.sololearn.com/Wn490jfvRgZC/?ref=app

12th Jul 2021, 3:53 PM
Khilesh Dewangan
5 ответов
+ 3
I think the problem is in the js function: Your function couldn't retrieve the current object colors. I changed it a little, see js. https://code.sololearn.com/WsX8qmZSv7Ye/?ref=app
12th Jul 2021, 4:41 PM
Lisa
Lisa - avatar
+ 2
Code works fine here, not sure what error you got, I don't see any. I click the button and the boxes switch colours no problem.
12th Jul 2021, 4:09 PM
Ipang
+ 1
Lisa, Thanks it's working now
12th Jul 2021, 5:06 PM
Khilesh Dewangan
+ 1
var color1 = id1.style.backgroundColor; var color2 = id2.style.backgroundColor; id1.style.backgroundColor = color2; id2.style.backgroundColor = color1;
12th Jul 2021, 5:16 PM
Solo
Solo - avatar
0
Ipang I don't know why it is not working on my device. But thanks for your answer :) Now it's fixed
12th Jul 2021, 5:08 PM
Khilesh Dewangan