[英]How to get the id of this div based upon search the inner html value?
How do I get the div id based upon the value "IBC-CW1 -DE-02A" 如何基于值“ IBC-CW1 -DE-02A”获取div ID
<div id="main">
<div id="hotspot1" class="drawing" data-canvas-width="89.91394117538998" style="left: 1397.52px;top: 1071.92px;font-size: 10.7966px;font-family: monospace;transform: scaleX(1.01043);background-color: #ff0000;">IBC-CW1 -DE-02A</div>
</div>
If i use parentnode means I am getting id="main" 如果我使用parentnode意味着我得到id =“ main”
How do i get hotspot1 我如何获得热点1
Update: 更新:
var spot.hotspot_hover = "IBC-CW1 -DE-02A"
$(".textLayer").each(function(){
$('.drawing').css('background-color','transparent');
if($(this).html().indexOf(spot.hotspot_hover) > -1){
var cont_redirect = $(this).parent()
console.log(cont_redirect[0])
$(cont_redirect).css('background-color','#ff0000');
$('#content-wrapper').animate({scrollTop: cont_redirect[0].offsetTop+300},'slow');
}
});
Now I have to give background color for that content 现在我必须为该内容提供背景色
Try the follwing jquery code 试试下面的jQuery代码
var divId = $("div.drawing:contains('IBC-CW1 -DE-02A')").attr('id');
console.log(divId);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.