给你的链接,并提醒每一个id
这样你就可以用JavaScript瞄准它,默认情况下也隐藏你的警觉,这样的事情:
<a id="testenv" href="www.footester.com/foofootestest">Test Environment #1</a>
<div id="testalert" style="display:none" class="alert alert-info">
<!-- ... -->
</div>
然后使用JavaScript当链路是火mouseover
事件徘徊是这样的:
var testenv = document.getElementById("testenv"),
testalert = document.getElementById("testalert");
testenv.addEventListener("mouseover", function(event) {
testalert.style.display = "block";
}, false);
只是为了好玩,你还可以添加一个mouseout
事件做出警报再次消失,当鼠标下车的链接(不徘徊了):
testenv.addEventListener("mouseout", function(event) {
testalert.style.display = "none";
}, false);
下面的代码片段块中的全部代码:
var testenv = document.getElementById("testenv"),
testalert = document.getElementById("testalert");
testenv.addEventListener("mouseover", function(event) {
testalert.style.display = "block";
}, false);
testenv.addEventListener("mouseout", function(event) {
testalert.style.display = "none";
}, false);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<a id="testenv" href="www.footester.com/foofootestest">Test Environment #1</a>
<div class="container">
<div id="testalert" style="display:none" class="alert alert-info">
<strong>Note: The testers are not using this link as a part of their test environment!</strong>
</div>
</div>
在这里,您可以与bootply代码(引导测试沙箱)玩:http://www.bootply.com/TfrhmIbqq8
看看[JavaScript的'addEventListener'功能与'mouseover'(https://developer.mozilla.org/en-US/docs/Web/Events/ mouseover)事件,或者如果你使用jQuery库(基本上是一个JavaScript框架),你可以利用它的['hover'](https://api.jquery.com/hover/)函数。 – webeno
你可以使用'a〜div' css规则:https://jsfiddle.net/khrismuc/ww6wqv7q/ –
你可能想要接受其中一个答案作为正确的答案... – webeno