고유 한 클래스 나 ID가없는 요소를 찾으려고합니다.(그런 다음 해당 요소의 부모를 찾아야합니다.)
Therefore it is not enough that you use:contains()selector, you also need to check if the text you search for is thedirect contentof the element you are targeting for, something like that:
따라서:contains()selector를 사용하는 것으로는 충분하지 않습니다.검색하는 텍스트가 대상 요소의직접 콘텐츠인지 확인해야합니다.
Element에 포함된 텍스트(Text)로 객체를 찾아라!
function findElementByText(text) {
var jSpot = $("b:contains(" + text + ")")
.filter(function() { return $(this).children().length === 0;})
.parent(); // because you asked the parent of that element
return jSpot;
}
and there are 5<li>'s on the page each with adata-slide=numberattribute(number being 1,2,3,4,5 respectively).
I now need to find the currently active slide number which is mapped tovar current = $('ul').data(current); and is updated on each slide change.
So far my tries have been unsuccessful, trying to construct the selector that would match the current slide:
$('ul').find(el+[data-slide=+current+]);
does not match/return anything…
The reason I can't hardcode thelipart is that this is a user accessible variable that can be changed to a different element if required, so it may not always be anli.