您的位置:首页 > Web前端 > JQuery

jQuery简单入门

2009-06-08 12:23 435 查看
首先在文件中引用:

<script type="text/javascript" src="../Library/jquery1.3.1/dist/jquery.js"></script>

<script type="text/javascript" src="hello.js"></script>

页面中有一个元素的类名为hello:

<div class=’hello’></div>

hello.js文件只有简单的内容:

$(document).ready(function() {
$('.hello').addClass('hellocss');
}); 其中hellocss为CSS样式表: .hellocss{
font-style: italic;
border: 1px solid #888;
padding: 0.5em;
margin: 0.5em 0;
background-color: #ffc;
} 这样打开页面后class为hello的div的样式就会设置成hellocss的样式.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: