首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > CSS >

js 放在html 的位置 不同 促成的结果页不相同

2013-02-24 
js 放在html 的位置 不同 造成的结果页不相同htmlhead? stylespan {display:none}/style? scrip

js 放在html 的位置 不同 造成的结果页不相同
<html>
<head>
? <style>span {display:none;}</style>
? <script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>

? <script>
??? $(document).ready(function() {
??? ??? $("input").focus(function () {
??? ??????? $(this).next("span").css('display','inline').fadeOut(1000);
??? ??? });
??? });
? </script>

<body>

? <p><input type="text" /> <span>focus fire</span></p>
? <p><input type="password" /> <span>focus fire</span></p>


</body>
</html>

?

?

?

例子2、代码可以正常执行:

?


<!DOCTYPE html>
<html>
<head>
? <style>span {display:none;}</style>
? <script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
? <p><input type="text" /> <span>focus fire</span></p>

<p><input type="password" /> <span>focus fire</span></p>
<script>
??? $("input").focus(function () {
???????? $(this).next("span").css('display','inline').fadeOut(1000);
??? });
</script>

</body>
</html>

?

例子3、代码中的js不能正常执行

?

<!DOCTYPE html>
<html>
<head>
? <style>span {display:none;}</style>
? <script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>

<script>
??? $("input").focus(function () {
???????? $(this).next("span").css('display','inline').fadeOut(1000);
??? });
</script>


<body>
? <p><input type="text" /> <span>focus fire</span></p>

<p><input type="password" /> <span>focus fire</span></p>

</body>
</html>

?

?

热点排行