style
Use the style property to remain consistent with native.
Please note that the style property cannot retrieve the actual value of a style but only the value set on the style property. Although the style method is similar to the css method, it cannot override all styles. Compared to css, the style method has a higher internal execution efficiency.
Here is an example that demonstrates how to use style:
<script src="https://cdn.jsdelivr.net/gh/kirakiray/ofa.js@4.5.26/dist/ofa.min.js"></script>
<div id="target">origin text</div>
<br>
<h4>logger</h4>
<div id="logger" style="border:#aaa solid 1px;padding:8px;"></div>
<script>
$("#logger").text = $("#target").style.color;
setTimeout(()=> {
$('#target').style.color = 'red';
$("#logger").text = $("#target").style.color;
}, 1000);
</script>
Please note that the style method only gets and sets values on the style property, not the actual computed style.