我的页面中有以下html.
<div id="bb-bookblock" class="bb-bookblock bb-vertical" style="height: 578.24885475px"> <div class="bb-item" style="display: none;"> <a href="#"> <img src="photorepository/admin/a-123/14/31 copy_200comp.jpg" alt="31 copy_200comp.jpg" style="height:100%"> </a> </div> <div class="bb-item" style="display: none;"> <a href="#"><img src="photorepository/admin/a-123/14/32 copy_200comp.jpg" alt="32 copy_200comp.jpg" style="height:100%"></a> </div> <div class="bb-item" style="display: none;"> <a href="#"><img src="photorepository/admin/a-123/14/4 copy_200comp.jpg" alt="4 copy_200comp.jpg" style="height:100%"></a> </div> <div class="bb-item" style="display: none;"> <a href="#"><img src="photorepository/admin/a-123/14/5 copy_200comp.jpg" alt="5 copy_200comp.jpg" style="height:100%"></a> </div> </div>
我需要转换style =“display:block;”具有特定alt的图像的类bb项的div.例如,如果alt是’5 copy_200comp.jpg’,那么该特定图像的父div将如下所示:
<div class="bb-item" style="display: block;"> <a href="#"><img src="photorepository/admin/a-123/14/5 copy_200comp.jpg" alt="5 copy_200comp.jpg" style="height:100%"></a></div>
我尝试了var src = $(‘img [alt =“example”]’)和类似的结构,但它们不起作用.