Reputation: 729
I'm trying to select the first element under id #pid which contains the .pe class but not the .break class. Then obviously get a certain attribute from that element. I have tried different variations the following doesn't seem to work:
$("#pid .pe:not(.break):first-child").attr("data-time");
neither does :
$("#pid .pe:first-child").not(".break").attr("data-time");
Can someone please tell me what's wrong with my logic.
Thanks
Upvotes: 1
Views: 38
Reputation: 4526
The problem is with the select of the first child.
This should look like this:
alert($("#pid .pe:not(.break)").first().attr("data-time"));
Or as per Jay's suggestion -
$('#pid .pe:not(.break):first').attr('data-time');
Upvotes: 1