Reputation: 107
I've got the following html
<ul id="navigationMenuTop" class="nav navbar-nav" data-bind="foreach: getRoutes">
<li data-bind="css: ..." >
<a data-bind="attr { href: ...">
This generates a nice top bar menu where users get to go to parts of the program where they have the rights for.
Now I need to get the li where the href in a contains 'registration'
I've tried several things, the latest being
$('.navigationMenuTop li a[href*="registration"]');
but no success yet, any ideas?
Upvotes: 0
Views: 164
Reputation: 14
$("#navigationMenuTop").on('click','li',function (){
alert($(this).text());
});
Upvotes: 0
Reputation: 618
You can use the parent function to get the parent of the matched anchor
$('#navigationMenuTop a[href*="registration"]').parent();
you can check this out here
Upvotes: 1
Reputation: 14573
I think you are mixing few things here.
This is not a knockout question, more of a jQuery + CSS questions.
navigationMenuTop
is ID - so you shouldn't access it with a dot
which means class.
Try # instead:
$('#navigationMenuTop li a[href*="registration"]');
Upvotes: 2