起步学习jQuery,代码很简单,如下:
<!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=gb2312" />
<title>Selected ShakeSpeare Plays</title>
<style type="text/css">
.brd{
border:3px double #ff0000;
}
</style>
<script src="jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$('div:eq{0}').addClass('brd');
});
</script></head>
<body>
<div>
123456abc</div>
<div>
def4532</div>
</body>
</html>
我用$('div:eq{0}')获取第一个div标签,为它设置样式,在IE6中可以看到效果,但在Firefox中却看不到效果,警告信息:警告:未知伪类或者伪元素 'eq'。请指点一下。
<!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=gb2312" />
<title>Selected ShakeSpeare Plays</title>
<style type="text/css">
.brd{
border:3px double #ff0000;
}
</style>
<script src="jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$('div:eq{0}').addClass('brd');
});
</script></head>
<body>
<div>
123456abc</div>
<div>
def4532</div>
</body>
</html>
我用$('div:eq{0}')获取第一个div标签,为它设置样式,在IE6中可以看到效果,但在Firefox中却看不到效果,警告信息:警告:未知伪类或者伪元素 'eq'。请指点一下。
$(document).ready(function(){
$('div:eq(0)').addClass('brd');//是()不是{}
});