Answer the question
In order to leave comments, you need to log in
How to remove the background-color from an element?
Good day.
Tell me how, when clicking on the #btn block, take the value of the background-color attribute from the #box1 element and display it as text in the #box-text block. It seems that it is not difficult, but it does not work.
<div id="box1" style="background-color: #cccccc; width: 100px;height: 100px;"></div>
<div id="btn" style="background-color: red; width: 50px;height: 50px;"></div>
<div id="box-text"></div>
Answer the question
In order to leave comments, you need to log in
$('#btn').click(function() {
let background_color = $('#box1').css('background-color');
$("#box-text").text(background_color);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question