Bug Tracker

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#12953 closed bug (duplicate)

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>

Change History (5)

comment:1 Changed 7 years ago by Rick Waldron

Owner: set to xorax
Status: newpending

Attribute selectors require quotes around the value

comment:2 Changed 7 years ago by xorax

Status: pendingnew

with quotes it does not work as well

comment:3 Changed 7 years ago by dmethvin

Resolution: duplicate
Status: newclosed

Duplicate of #12792.

comment:4 Changed 7 years ago by xorax

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?

comment:5 Changed 7 years ago by dmethvin

No. Ask for help on the forum.

Note: See TracTickets for help on using tickets.