- 如题
-
上代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <style type="text/css"> <!-- .mainfram{font-size:12px;} .mainfram span { cursor:hand; color:blue; } .afont{font-size:20px; color:blue;} .bfont{font-size:16px; color:green;} --> </style> </head> <body id="contentfram"> <div class="mainfram"> <span onclick= "contentfram.className='afont';">大字体</span> | <span onclick= "contentfram.className='bfont';">小字体</span> </div> </body> </html>
- 单击“大字体”“小字体”都无反应。
另外鼠标停留在“大字体”“小字体”并没有CSS样式中的hand - 出处:《新手学HTML+CSS》P262 示例16.1
afont和bfont类是已经添加成功的, 但是你是加在了body上, 所以样式是继承body的, 权重太低, 使用的是你设定的样式, 所以看不出效果.
这样试试, 这样加在span上, 友情提示: this关键字在javascript是极其重要, 要重点掌握