I’m not really well educated in jQuery, but I need a selector for the following:
<div class="shepherd-step shepherd-theme-dark shepherd-has-title shepherd-element shepherd-element-attached-top shepherd-element-attached-center shepherd-target-attached-bottom shepherd-target-attached-center shepherd-open shepherd-enabled"
data-id="DataType">
<div class="shepherd-content">
<header><h3 class="shepherd-title">Data Type</h3></header>
<div class="shepherd-text"><p>Choose Your Desired Data Type!</p></div>
<footer><ul class="shepherd-buttons">
<li><a class="shepherd-button shepherd-button-secondary">Close</a></li>
<li><a class="shepherd-button shepherd-button-example-primary">Next</a></li></ul>
</footer>
</div>
</div>
Fields of Interests: shepherd-step
/ data-id="DataType"
/ shepherd-button-example-primary
but I have a knowledge gap to handle it with JQuery
I tried something like this: .shepherd-step[data-id="DataType"] > .shepherd-button-example-primary
to address [data-id="DataType"]
working fine, but I want the button and not the whole div
2
Answers
It is pretty simple to do you just have to use
$("CSS selector")
you can use all the CSS selectors in jquery to select a certain element from DOM.**Here is this example I changed the text of both the buttons using jQuery **
Remove the
>
from your selector so it becomes:The use of the Child Combinator
>
means that the button must be a direct child of theshepherd-step
div. This is the reason it did not work. By removing the child combinator, you’re using the Descendent Combinator, and the button is a descendent of the div; therefore, the button will be found.