Reputation: 146
I have been trying to get the selector that matches the following:
Title > Prints > Ginger
How do i select "Ginger" via jquery
code for the above are:
<span class="selectednav">
<a href="http://mysite.com/">Title</a>
<span class="navigation-pipe"> > </span>
<a href="http://mysite.com/20-prints">Prints</a>
<span class="navigation-pipe"> > </span>
Ginger
</span>
Any help would much be appreciated
Thanks
Upvotes: 1
Views: 81
Reputation: 2265
full edit sorry first answer not adapted // although not sure this works to be honest
$('.selectednav').contents().filter(
function() { if (this.nodeType == 3) $(this).wrap("<span class='orphan'></span>"); });
$orphan = $('.selectednav').find(".orphan");
edit in one line for perf sake :
$orphan = $('.selectednav').contents().filter(
function() { if (this.nodeType == 3) $(this).wrap("<span class='orphan'></span>"); }).end().find(".orphan");
also each would work instead of filter
then if only to get the text this should do
orphantext= $('.selectednav').contents().filter(
function() { return this.nodeType == 3; })
.text();
Upvotes: 1
Reputation: 154
This Link might be what your looking for
I think the code may look like this if you have a div around the code you have presented
$("div span").last()
Upvotes: 0
Reputation: 11
Something like $(".selectednav").find(".navigation-pipe").last() should work.
Upvotes: 0