Search code examples
jquerysyntaxfind

JQuery find() syntax not working in v 1.12


I have some legacy JQuery code in version 1.4.3 and i'm trying to upgrade to version 1.12.4 (before eventually upgrading to v 3.x).

However, this piece of code that used to work in 1.4 is no longer working after I upgraded to 1.12.

var str = $("#fav-inst-table")
.find("tr:has(td:has(input:checkbox[id^='fav_doc_'][checked]))")

I read over the upgrade logs and instructions and i'm not too sure what can contribute to the code not working. I'm not too much of a JQuery expert, sorry if my question seems dumb.

The selector $("#fav-inst-table") returns the expected value just fine (in Edge debugger), it's the "find" function that no longer works with the current syntax, and returns nothing.


Solution

  • took a while for us to finally debug the issue but it seems, even though jsfiddle says this syntax is correct for 1.12.4, our environment which runs on java JDK 1.8 does not recognize this specific syntax for some reason.

    What worked for us was var str = $("#fav-inst-table") .find("tr:has(td:has(input:checkbox[id^='fav_doc_']:checked))")

    instead of [checked] it was :checked.

    If anyone has any input as to why :checked worked instead of [checked] I would appreciate the input too, in case we run into similar situation with syntax in the future. Thanks.