-1
  <ul class="xyz">
     <li data-et-id="p">
     <li data-et-id="A">
     ...
     ..
     ...
    <li data-et-id="m">...
     ...
     ...
  </ul>

I tried $('ul.xyz li[data-et-id=A]'). This works but

here's what I'm trying to do .. I have a page with many <ul>. Within each <ul> tag I have <li>. Now when I hit load more , the next set of <ul> gets loaded on the page. I am trying to use the selector above to filter <li> with id="A" in all the <ul> with classname=xyz. When load more is clicked, it's an ajax call which loads more content each time it's clicked.

The question is that , though the selector works, it filters out the <li> with data-et-id=A which is there on the page but does not show the <li> with data-et-id="A" which appear after the load more button is clicked.

Rodrigo Medeiros
  • 7,814
  • 4
  • 43
  • 54
user2821242
  • 1,041
  • 3
  • 9
  • 16

1 Answers1

1

According your markup, this should do it. Your wording is a bit unclear.

$('.xyz li[data-et-id=A]');

Live demo (click).

This is using the attribute selector. The syntax is:

selector[attribute=value]
m59
  • 43,214
  • 14
  • 119
  • 136
  • Thanks, the above selector works but here's what I'm trying to do .. I have a page with many
      . Within each
        tag I have
      • . Now when I hit load more , the next set of
          gets loaded on the page. I am trying to use the selector above to filter
        • with id="A" in all the
            with classname = xyz. When load more is clicked, it's an ajax call which loads more content each time it's clicked.
    – user2821242 Jan 26 '14 at 02:05
  • @user2821242 I'm not sure why you told me that, lol. Do you have a question? – m59 Jan 26 '14 at 02:11
  • yeah. The question is that , though the selector works, it filters out the
  • with data-et-id=A which is there on the page but not the one's which appear after the load more button is clicked. Hope I'm clear this time
  • – user2821242 Jan 26 '14 at 02:14
  • @user2821242 then filter it again when you load more items :) – m59 Jan 26 '14 at 02:15
  • no I mean I am trying to filter out the data from page "I" and fetching it into page "II". So basically whichever items on page "I" with loadmore have
  • with data-et-id ="A" should appear on page "II". So on page "II" , I only have
  • with data-et-id="A" & on page "I" , I have many
  • 's
  • – user2821242 Jan 26 '14 at 02:21
  • @user2821242 I still don't see the problem. You have a selector to filter them with. Use it whenever you need it! Also, don't forget to accept my answer by clicking the checkmark to the left of it. – m59 Jan 26 '14 at 02:28
  • yep I accepted your answer. But I still see the problem. I want to see the data on page "II" without initiating any loadmore or ajax call. So when the user directly goes to page "II" he wont have to click load more on page"I" and then get the contents on page "II" . – user2821242 Jan 26 '14 at 02:36
  • @user2821242 you didn't accept the answer... I don't mind helping, but you should at least give me some credit. – m59 Jan 26 '14 at 02:39
  • I have accepted your answer. Not sure why you saying that :X – user2821242 Jan 26 '14 at 02:42
  • @user2821242 I've never seen it be that late before. I'll take your word for it. You really need to make a demo on something like http://plnkr.co and post a new question. I'd be glad to help, but you're not going to be able to give enough detail in these comments. Make a demo and post the link and I'll take care of it – m59 Jan 26 '14 at 02:43