Javascript工具提示不工作,不知道为什么
Javascript tooltip not working, no idea why
在滑块中,我创建了可以展开并显示工具提示的图像,但是由于某种原因,我之前的功能代码不再工作。完全相同的代码可以在JSFiddle上工作,但不能在线或本地工作。我不知道为什么。
HTML<ul class="thumb">
<li> <img src="imagewithtooltip.png" width="200" height="229" title="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse tincidunt rhoncus risus sed rhoncus." /> </li>
</ul>
CSS ul.thumb {
float: none;
list-style: none;
margin: 0;
padding: 10px;
width: 360px;
bottom: 5px;
}
ul.thumb li {
margin: 0;
padding: 5px;
float: right;
position: absolute; /* Set the absolute positioning base coordinate */
width: 200px;
height: 200px;
bottom: 5px;
right: 40%;
}
ul.thumb li img {
width: 200px;
height: 200px; /* Set the small thumbnail size */
-ms-interpolation-mode: bicubic;
padding: 5px;
position: relative;
left: 0;
top: 0;
}
.hover {
background:url(thumb_bg.png) no-repeat center center;
}
.caption {
background:#ffcc00;
position: absolute;
top: 100%;
left: 0px;
}
Javascript <script type="text/javascript">
$("ul.thumb li").hover(function() {
$(this)
.css('z-index', '10')
.find('img').addClass("hover")
.stop()
.animate({
marginTop: '-150px',
marginLeft: '-150px',
top: '50%',
left: '50%',
width: '300px',
height: '300px',
padding: '20px'
}, 200, function() {
var $this = $(this),
h = $this.height();
$caption = $('<div class="caption">' + this.title + '</div>')
.css('top', h.toString() + 'px');
$this.after($caption);
});
}, function() {
$('.caption').remove();
$(this)
.css('z-index', '0')
.find('img').removeClass("hover")
.stop()
.animate({
marginTop: '0',
marginLeft: '0',
top: '0',
left: '0',
width: '200px',
height: '200px',
padding: '5px'
}, 400);
});
</script>
网页的现场链接在这里,我刚刚和一个朋友完成了平面设计课程,他是一个网页设计师哈哈!
我在这篇文章中添加了一个js提琴。这种做法现在正在发挥作用。点击这个链接并查看。http://jsfiddle.net/kabircse/RNt6Z/
使用java脚本代码:
<script type="text/javascript">
$(function(){
$("ul.thumb li").hover(function() {
$(this)
.css('z-index', '10')
.find('img').addClass("hover")
.stop()
.animate({
marginTop: '-150px',
marginLeft: '-150px',
top: '50%',
left: '50%',
width: '300px',
height: '300px',
padding: '20px'
}, 200, function() {
var $this = $(this),
h = $this.height();
$caption = $('<div class="caption">' + this.title + '</div>')
.css('top', h.toString() + 'px');
$this.after($caption);
});
}, function() {
$('.caption').remove();
$(this)
.css('z-index', '0')
.find('img').removeClass("hover")
.stop()
.animate({
marginTop: '0',
marginLeft: '0',
top: '0',
left: '0',
width: '200px',
height: '200px',
padding: '5px'
}, 400);
});
});
</script>
相关文章:
- 这个旋钮没有更新;我不知道为什么
- 我不知道为什么我的代码是错误的?又有什么错
- I'我不知道为什么我的代码没有'不起作用
- sqlite查询返回错误-can'我不知道为什么
- 我没有'我不知道为什么我的jqGrid子网格没有'不要给我看数据
- 我的代码很完美,但我现在不知道为什么我发现了问题
- 变量不起作用(不知道为什么)javascript
- 我可以'不要让这几行简单的代码正常工作,也不知道为什么
- 我的素数函数坏了,但我没有;我不知道为什么
- 当我从struts2操作在js函数中获得JSONArray时,它是空的,我不知道为什么
- 可以'我不知道为什么这个数字赢了;t增量
- 我不知道为什么ng repeat在我的代码中不起作用
- 标题下方的标签在再次单击时消失,JavaScript不知道为什么
- 历史.推送状态错误,我不知道为什么
- 只是不工作,不知道为什么
- 我的 innerHTML 命令没有改变任何东西,我不知道为什么
- JavaScript Validator 一直在说关于第 11 行的意外“如果”,我不知道为什么
- 我的地理位置(javascript)不起作用,我不知道为什么
- 我不知道为什么这个画布是空的
- 不知道为什么我的服务器超时.