Skip to main content

Bug Tracker

Side navigation

#12953 closed bug (duplicate)

Opened November 24, 2012 10:49PM UTC

Closed November 25, 2012 03:51AM UTC

Last modified November 25, 2012 02:40PM UTC

index() does not search using [attr=value] selectors

Reported by: xorax Owned by: xorax
Priority: undecided Milestone: None
Component: unfiled Version: 1.8.3
Keywords: Cc:
Blocked by: Blocking:
Description

it seems jquery incorrectly handles selectors in index() method. To demonstrate the issue I have created a code sample

<!DOCTYPE html>
<html>
<head>
  <script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
  <script type="text/javascript">
    $(function(){
      // this works
      console.log($('p').filter('[data-custom-id=36]'));

      //this doesnt
      console.log($('p').index('[data-custom-id=36]'));
    })
  </script>
</head>
<body>
  <p data-custom-id="342">
    342
  </p>
  <p data-custom-id="36">
    36
  </p>
  <p data-custom-id="57647">
    57647
  </p>
  <p data-custom-id="433">
    433
  </p>

</body>
</html>
Attachments (0)
Change History (5)

Changed November 24, 2012 11:15PM UTC by rwaldron comment:1

owner: → xorax
status: newpending

Attribute selectors require quotes around the value

Changed November 24, 2012 11:18PM UTC by xorax comment:2

status: pendingnew

with quotes it does not work as well

Changed November 25, 2012 03:51AM UTC by dmethvin comment:3

resolution: → duplicate
status: newclosed

Duplicate of #12792.

Changed November 25, 2012 09:41AM UTC by xorax comment:4

I do not agree this bug is duplicate of #12792!

In my case index() does not work at all. It returns -1 when filter() with the same parameters returns non-empty set.

Shouldn't index() and filter() work in a similar way?

Changed November 25, 2012 02:40PM UTC by dmethvin comment:5

No. Ask for help on the forum.