Home > Web Front-end > JS Tutorial > Write complex JavaScript scripts in CSS_javascript skills

Write complex JavaScript scripts in CSS_javascript skills

WBOY
Release: 2016-05-16 19:05:26
Original
1228 people have browsed it

Because "{" and "}" conflict with "{" and "}" in CSS.
It seems that quotation marks cannot be used, and there is no specific test.
In this way, writing scripts in CSS is easy It is not flexible anymore, but if you want to write a complex script into CSS, how should you deal with it? This is a question. After testing, you can first define a function and then call it in expression. However, since it is used in CSS expression, therefore, can only be run in IE.
The following is an example, click on the code to run.

[Ctrl A select all Note: If you need to introduce external Js, you need to refresh to execute
]
<script> ex=function(){ if(document.getElementById("dg")!=null){ return document.getElemntById("dg").offsetWidth; }else{ return 500; } } </script>
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