6

Im trying to execute the following code below, but it throws the following error message:

Error: Syntax error, unrecognized expression: unsupported pseudo: really-good-at

The code:

<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript">
    /* Implement a Cesar crypto decrypt for the code.
    * [Code ASCII] + n => Decrypted ASCII.
    * where n = char pos in cryptedCode string (R=1) */

if ($('.js.php.mysql.html.oop').is(':really-good-at')) {
    var cryptedCode = 'RFLLDN';
    var decryptedCode = '';
    console.log('Enter this code in the form: ' + decryptedCode);
    //Open website url
    var url = 'aHR0cDovL2JpdC5seS8xN21NRzk4';
    window.open(window.atob(url));
}
</script>
<input type="text" class="js.php.mysql.html.oop">

Anyone who can explain why this error is thrown?

Irvin Dominin
  • 30,819
  • 9
  • 77
  • 111
user500468
  • 1,183
  • 6
  • 21
  • 36

3 Answers3

17

You can see jQuery's list of valid selectors here: http://api.jquery.com/category/selectors/

Your problem is simply that :really-good-at is not a valid selector.

If really-good-at is a class name, you could use .is('.really-good-at')

doctororange
  • 11,670
  • 12
  • 42
  • 58
2

Well, the error is clear...really-good-at is NOT a recognized css pseudo selector. You can't just use arbitrary pseudo selectors and expect it work. It's like me trying to speak Spanish in Japan and expecting japanese people to understand what I'm saying

Leo
  • 14,625
  • 2
  • 37
  • 55
0

A very similar experience just happened to me with a pseudo selector that just didn't make sense. The problem is...it was in my own code!

This is how it was born: - initially it was a valid CSS expression: "td:nth-of-type" used within a callback function, so far so normal. Until I decided to select the whole of that function, and do a massive find/replace on the selected text: replace "type" with "action". Why? Because one of the arguments of that callback was wrongly named "type" instead of "action". This is how my pseudo selector ended up as "nth-of-action", hence triggering a JS error, which in turn stopped processing the rest of the code. As much as I know by experience that massive replaces are dangerous, I still reviewed my code to look for instances of "action", but I didn't see that the pseudo selector nth-of-type has been changed...

Fabien Haddadi
  • 1,814
  • 17
  • 22