发布于2021-06-16 09:44 阅读(1213) 评论(0) 点赞(0) 收藏(4)
我使用教程http://www.webdesignlondon-tristar.co.uk/website-design-london/insane-jquery-image-rollover。
我想要图像在翻转时褪色/变暗,并使文本像教程中一样显示。但是由于某种原因,即使在启动空白文档时,我似乎也无法让它工作。
这不是我第一次使用 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=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
.wrapper { padding: 8px; background-color: #fff; border: 1px #0d5a2c solid; position: relative; width:300; height: 300; margin: 0 auto; }
.wrapper:hover { cursor: pointer; }
.description { display: none; background-color: #000; color: #000; position: absolute; left: 8px; top: 8px; text-decoration: none; font-size: 1.5em; width: 250px; height: 130px; padding: 120px 0 0 0; }
.description img { vertical-align: middle; margin: 0 2px 1px 0; }
</style>
<script src="jquery-1.3.1.min.js" type="text/javascript">
$(document).ready(function(){
$('.wrapper').hover(function(){
$(this).children('.description').stop().fadeTo(200, 0.8);
},function(){
$(this).children('.description').stop().fadeTo(200, 0);
});
});
</script>
</head>
<body>
<div class="wrapper">
<img src="http://www.compuhex.co.uk/Version2/products2/blue.PNG" alt="Product 1" />
<a href="#" title="Click for More" class="description">
Want to read more?
</a>
</div>
</body>
</html>
可以在http://www.compuhex.co.uk/Version2/hovertext/上看到实时链接
抱歉,如果代码很乱。
谢谢大家的帮助
所以总结一下,我想看看为什么代码不起作用,即使它是来自教程站点的副本。所展示的技术正是我想对我的网站做的事情。谢谢
您使用旧版本的 jQuery (1.3.1) 它将在版本 > 1.4 时按预期工作(就目前而言);
在您将ready
代码包装在<script src=..
元素中的示例中,您需要将两者分开,即:
<script src="jquery-1.7.2.min.js" type="text/javascript">
$(document).ready(function(){
...
</script>
至:
<script src="jquery-1.7.2.min.js" type="text/javascript"></script>
<script type='text/javascript'>
$(document).ready(function(){
...
</script>
作者:黑洞官方问答小能手
链接:http://www.qianduanheidong.com/blog/article/130274/8bbd503936387faca583/
来源:前端黑洞网
任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任
昵称:
评论内容:(最多支持255个字符)
---无人问津也好,技不如人也罢,你都要试着安静下来,去做自己该做的事,而不是让内心的烦躁、焦虑,坏掉你本来就不多的热情和定力
Copyright © 2018-2021 前端黑洞网 All Rights Reserved 版权所有,并保留所有权利。 京ICP备18063182号-3
投诉与举报,广告合作请联系vgs_info@163.com或QQ3083709327
免责声明:网站文章均由用户上传,仅供读者学习交流使用,禁止用做商业用途。若文章涉及色情,反动,侵权等违法信息,请向我们举报,一经核实我们会立即删除!