Home > Web Front-end > JS Tutorial > body text

Analysis of the differences between style, currentStyle and runtimeStyle_javascript skills

WBOY
Release: 2016-05-16 18:22:06
Original
1143 people have browsed it

1. obj.style can only obtain the inline style (inline Style) that is written in the Tag. It cannot access the external css of those links and the style declared with


1111


<script> <br>alert(document.getElementById("tt"). currentStyle.color); <br></script>


If the style in the above
is removed, it will be
1111
, then currentStyle.color becomes yellow according to the priority, but style.color is empty at this time.
3. RuntimeStyle simply means that you can assign a value to the style of a node, and it will become the node style with the highest priority. " -//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

1111

<script> <br>document.getElementById("tt").runtimeStyle.color="black"; <br>alert(document.getElementById(" tt").currentStyle.color); <br>alert(document.getElementById("tt").runtimeStyle.color); <br>alert(document.getElementById("tt").style.color); <br> </script>



The color of the words displayed on the page at this time is black after the runtimeStyle is assigned. But only currentStyle.color and runtimeStyle themselves can get this value, and style.color still gets the blue in the tag.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!