1 回答
TA贡献1844条经验 获得超8个赞
<!DOCTYPE html>
<html>
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h3>Demo</h3>
<a href="#" data-toggle="tooltip" title="Tooltip is visible!">Tooltip will be visible here</a>
<a href="#" data-toggle="tooltip" title="Tooltip is visible!">Tooltip will be visible here</a>
<div>
<button type="button" class="btn btn-primary">Show Tooltip</button>
<button type="button" class="btn btn-default">Hide Tooltip</button>
</div>
</div>
<script>
//make sure to comment this lines
//works fine I can see tooltips by default
// $("[data-toggle='tooltip']").tooltip();
// $("[data-toggle='tooltip']").tooltip('show');
$(document).ready(function () {
$(".btn-primary").click(function () {
// works fine on IE11
$("[data-toggle='tooltip']").tooltip();
$("[data-toggle='tooltip']").tooltip('show');
});
$(".btn-default").click(function(){
$("[data-toggle='tooltip']").tooltip();
$("[data-toggle='tooltip']").tooltip('hide');
});
});
</script>
</body>
</html>
添加回答
举报