Javascript 引导悬停图像显示示例
当用户将鼠标悬停在链接上时,我会尝试显示一个简单的图像,我会按照字母的顺序进行操作,但我不会显示任何图像 我有以下UI,当用户单击view fleet时,数据将异步返回,示例代码放在返回数据的脚本中,因此: 用户单击查看车队 代码Javascript 引导悬停图像显示示例,javascript,jquery,css,ajax,twitter-bootstrap,Javascript,Jquery,Css,Ajax,Twitter Bootstrap,当用户将鼠标悬停在链接上时,我会尝试显示一个简单的图像,我会按照字母的顺序进行操作,但我不会显示任何图像 我有以下UI,当用户单击view fleet时,数据将异步返回,示例代码放在返回数据的脚本中,因此: 用户单击查看车队 代码 $('a[rel=popover]').popover({ html: true, trigger: 'hover', placement: 'bottom', content: function(){return '<img src="'+
$('a[rel=popover]').popover({
html: true,
trigger: 'hover',
placement: 'bottom',
content: function(){return '<img src="'+$(this).data('img') + '" />';}
});
$('a[rel=popover]')。popover({
是的,
触发器:“悬停”,
位置:'底部',
内容:函数(){返回“”;}
});
ViewFleet.php
<td> <a class="btn" rel="popover" data-img="//placehold.it/400x200"> <?php echo $row['model'] ?></a></td>
非常感谢您对上述内容的任何帮助或建议。请尝试以下代码,以帮助您在悬停时显示图像:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('[data-toggle="popover"]').popover({
placement : 'top',
trigger : 'hover',
html : true,
content : '<div class="media"><a href="#" class="pull-left"><img src="image2.png" class="media-object" alt="Sample Image"></a><div class="media-body"></div></div>'
});
});
</script>
<style type="text/css">
.bs-example{
margin: 200px 150px 0;
}
.bs-example button{
margin: 10px;
</style>
</head>
<body>
<div class="bs-example">
<button type="button" class="btn btn-primary" data-toggle="popover">Popover with image</button>
</div>
</body>
</html>
$(文档).ready(函数(){
$('[data toggle=“popover”]')。popover({
位置:'顶部',
触发器:“悬停”,
是的,
内容:“”
});
});
.bs示例{
保证金:200px 150px 0;
}
.bs示例按钮{
利润率:10px;
带图像的Popover
请尝试以下代码,它将帮助您在悬停时显示图像:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('[data-toggle="popover"]').popover({
placement : 'top',
trigger : 'hover',
html : true,
content : '<div class="media"><a href="#" class="pull-left"><img src="image2.png" class="media-object" alt="Sample Image"></a><div class="media-body"></div></div>'
});
});
</script>
<style type="text/css">
.bs-example{
margin: 200px 150px 0;
}
.bs-example button{
margin: 10px;
</style>
</head>
<body>
<div class="bs-example">
<button type="button" class="btn btn-primary" data-toggle="popover">Popover with image</button>
</div>
</body>
</html>
$(文档).ready(函数(){
$('[data toggle=“popover”]')。popover({
位置:'顶部',
触发器:“悬停”,
是的,
内容:“”
});
});
.bs示例{
保证金:200px 150px 0;
}
.bs示例按钮{
利润率:10px;
带图像的Popover
此代码正在运行:
- 添加引导和jquery
- 在请求图像url时添加http: 无服务器测试(只需在浏览器中打开文件),无需http请求
ABC测试
$('a[rel=popover]')。popover({
是的,
触发器:“悬停”,
位置:'底部',
内容:函数(){返回“”;}
});
此代码正在运行:
- 添加引导和jquery
- 在请求图像url时添加http: 无服务器测试(只需在浏览器中打开文件),无需http请求
ABC测试
$('a[rel=popover]')。popover({
是的,
触发器:“悬停”,
位置:'底部',
内容:函数(){返回“”;}
});
你有工具提示插件吗?@monkeyinsight我没有…让我检查一下quicky@monkeyinsight抱歉,如果我在这里很愚蠢,但我看不到工具提示插件…弹出窗口要求工具提示插件包含在您的引导版本中。您在控制台中是否有任何错误?@TimothyCoetzeedid您包含工具提示插件?@monkeyinsight我没有。让我查一查quicky@monkeyinsight抱歉,如果我在这里很愚蠢,但我看不到工具提示插件…弹出窗口要求工具提示插件包含在您的引导版本中。您在控制台中有任何错误吗?@TimothyCoetzee谢谢您进行了一个小调整,但成功了。您进行了一个小调整,但成功了