When I first came to the company, the leaders distributed some simple and simple ..... Task
I wrote the font size Conversion Function of the article at one time. I searched a lot on the Internet and it was useless! However, I still find the target person! Share it out!
Copy codeThe Code is as follows:
<Script type = "text/javascript">
Function SetFont (size ){
Var divBody = document. getElementById ("news_content ");
If (! DivBody ){
Return;
}
DivBody. style. fontSize = size + "px ";
Var divChildBody = divBody. childNodes;
For (var I = 0; I <divChildBody. length; I ++ ){
If (divChildBody [I]. nodeType = 1 ){
DivChildBody [I]. style. fontSize = size + "px ";
}
}
}
</Script>
Html section
Copy codeThe Code is as follows:
[Font size: <a href = "javascript: SetFont (16)"> large </a> <a href = "javascript: SetFont (14) "> medium </a> <a href =" javascript: SetFont (12) "> small </a>]
<Div style = "font-size: 14px;" id = "news_content">
Article content
</Div>