我需要根据我悬停的图片更改三张堆叠图片的显示样式。显然,使用CSS O(log(n))
进入父级和下一级是不可能的。
我尝试使用我发现的部分代码来使其正常工作。 JavaScript适用于第一个孩子,但我不能让它显示第二个孩子。
HTML:
:hover
JS:
<div class="c-tab is-active">
<div class="c-tab__content">
<div class="row" id="mapviewer">
<div class="col-xs-4 nopadding" style="" id="d_d2">
<div class="dd21 viewer1" id="test111">
<img class="map" src="images/d/dd2.png" >
<img class="map" src="images/hover1/mockuptopage_01.png" >
<img class="map" src="images/hover2/mockuptopage_01.png" >
</div>
</div>
<div class="col-xs-4 nopadding" style="" id="n_d2">
<div class= "nd21 viewer2" id="test222">
<img class="map" src="images/n/dd2.png" >
<img class="map" src="images/hover2/mockuptopage_03.png" >
<img class="map" src="images/hover3/mockuptopage_01.png" >
</div>
</div>
<div class="col-xs-4 nopadding" style="" id="s_d2">
<div class="sd21 viewer3" id="test333">
<img class="map" src="images/s/dd2.png">
<img class="map" src="images/hover2/mockuptopage_03.png">
<img class="map" src="images/hover3/mockuptopage_01.png" >
</div>
</div>
</div>
</div>
答案 0 :(得分:3)
您应该使用jQuery选择器:nth-child()选择器
let statementValue = sqlite3_column_text(statement, 2)
var sText = withUnsafeMutablePointer(&statementValue) {UnsafeMutablePointer<Void>($0)}
答案 1 :(得分:1)
$('#test111').on('mouseover', function() {
$("#test222 img:nth-child(2)").css('display', "inline-block");
}).on('mouseout', function() {
$("#test222 img:nth-child(2)").css('display', "none");
})
或没有jquery:
$('#test111').on('mouseover', function(){
document.querySelector("#test222 img:nth-child(2)").style.display = "inline-block";
}).on('mouseout', function(){
document.querySelector("#test222 img:nth-child(2)").style.display = "none";
})
答案 2 :(得分:0)
$('#test111').on('mouseover', function() {
$("#test222")[1].css('display', "inline-block");
}).on('mouseout', function() {
$("#test222")[1].css('display', "none");
})
这应该有效