[英]twitter bootstrap tooltip with images
I am currently using twitter bootstrap to add tooltips. 我目前正在使用twitter bootstrap添加工具提示。
Heres my JS: 继承我的JS:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css"/>
<script src="http://twitter.github.com/bootstrap/assets/js/bootstrap-tooltip.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("a img").tooltip({'placement': 'right'});
});
</script>
I am trying to append an image with jquery with the rel attr for tooltips like this: 我试图用jquery附加一个带有rel attr的图像,用于这样的工具提示:
$(".info").append('<a href="#" rel="tooltip" title="first tooltip"><img src="http://extrarewards.nationalexpress.com/images/assets/info_icon.png"/></a>');});
Without the image this works, but as soon as i add the image in it stops working. 没有图像,这是有效的,但只要我添加图像停止工作。
Any ideas what is wrong with the above? 任何想法上面有什么问题?
The syntax on your .append
is off. .append
上的语法已关闭。 Try: 尝试:
$(".info").append('<a href="#" rel="tooltip" title="first tooltip"><img src="http://extrarewards.nationalexpress.com/images/assets/info_icon.png"></a>');
Demo: Bootply.com/65857 演示: Bootply.com/65857
Hi it seem to be you have solved your problem. 嗨,好像你已经解决了你的问题。 But I would like to give a different solution for your problem.
但我想为您的问题提供不同的解决方案。 I personally use this method to add tooltip texts to images.
我个人使用这种方法向图像添加工具提示文本。
Here is my HTML part. 这是我的HTML部分。
<a href="#" data-toggle="tooltip" title="Your tool tip text here."><img src="imgs/sample.png"></a>
Now here is the Jquery part 现在这里是Jquery部分
<script>
$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip();
});
</script>
If you want to know more about bootstrap tooltips you could refer this . 如果您想了解有关bootstrap工具提示的更多信息,可以参考这个 。
Best way in my view 在我看来最好的方式
<a href="#" data-toggle="tooltip" data-placement="bottom" title="<img src='../../images/mrraja.jpg' width='105' height='130' />">1</a>
<script>
$(document).ready(function(){
$('a[data-toggle="tooltip"]').tooltip({
animated: 'fade',
placement: 'bottom',
html: true
});
});
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.