我使用的是图片src
<li class="col-xs-6 col-sm-4 col-md-3 disp" data-src="uploads/slider_img/negy.jpg">
<a href=""><img class="img-responsive" src="uploads/slider_img/negy.jpg"></a>
<div class="content"><img class="imageclass" src="img/hotspot.png" width="30px" height="30px" data-toggle="modal" data-target="#myModal1" style="top:243px; left:1024px; z-index: 1; position: absolute;">
<div class="child" style="top:234px; left:1074px;">
<h4>dfgh</h4>
<p>fghdg</p>
<div class="triangle-down"></div>
</div>
</div>
</li>
如何调用内容子类依赖图像src
<li class="col-xs-6 col-sm-4 col-md-3 disp" data-src="uploads/slider_img/negx.jpg">
<a href=""><img class="img-responsive" src="uploads/slider_img/negx.jpg"></a>
<div lass="content"><img class="imageclass" src="img/hotspot.png" width="30px" height="30px" data-toggle="modal" data-target="#myModal1" style="top:490px; left:1188px; z-index: 1; position: absolute;">
<div class="child" style="top:481px; left:1238px;">
<h4>sa</h4>
<p>sas</p>
<div class="triangle-down"></div>
</div>
</div>
</li>
答案 0 :(得分:0)
为了选择下一个div.content
,您可以使用Javascript或jQuery。
以下是使用您的代码的示例:
$(document).ready(function() {
$('img').each(function() {
if ($(this).attr('src') === 'uploads/slider_img/negx.jpg') {
$(this).parent().next().css("background-color", "red");
}
});
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<li class="col-xs-6 col-sm-4 col-md-3 disp" data-src="uploads/slider_img/negx.jpg">
<a href="">
<img class="img-responsive" src="uploads/slider_img/negx.jpg">
</a>
<div class="content">
<img class="imageclass" src="img/hotspot.png" width="30px" height="30px" data-toggle="modal" data-target="#myModal1" style="top:490px; left:1188px; z-index: 1; position: absolute;">
<div class="child" style="top:481px; left:1238px;">
<h4>sa</h4>
<p>sas</p>
<div class="triangle-down"></div>
</div>
</div>
</li>
&#13;
备注:强>
each()
src
属性与我要查找的路径相匹配,请使用parent()
进入层次结构,并选择下一个next()
css()