Reputation: 221
I want to use the gt()
selector within a .load()
method. Can this be accomplished?
At the moment, I am seeking a solution which would allow me to apply a .children(':gt(0)')
selector after .entry:first
is called.
Here is my progress, so far:
$("#embed-content").load("https://URL.com/page/ .entry:first .children(':gt(0)')", function(data) {});
Note, the first element from the load source will not always be a div
, and will not always contain the same id or class, these aspects will vary.
Upvotes: 0
Views: 44
Reputation: 1074585
.entry:first .children(':gt(0)')
would be .entry:first > :gt(0)
. The >
is the direct child combinator, and then of course :gt(0)
is "greater than index 0".
I don't think that's what you want though. In a comment you've said:
I am trying to select the first child element within the first
.entry
div from the loaded page source.
:gt(0)
will skip the first such element, rather than selecting it. To select it you want: .entry:first > :first
:
$(".entry:first > :first").css({
color: "green",
fontWeight: "bold"
});
<div class="entry">
<span>first child of first .entry</span>
<span>second child of first .entry</span>
</div>
<div class="entry">
<span>first child of second .entry</span>
<span>second child of second .entry</span>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
Upvotes: 1