jQuery:什么是"输入[@checked],输入[@type ='text']"发现?

Bee*_*Bee 4 jquery jquery-selectors

我继承了一些javascript,并不是所有的工作都在按预期进行.这是一个难点:

jQuery("#theForm")
  .find("input[@checked], input[@type='text'], options[@selected], textarea")
  .each(function() { ... });
Run Code Online (Sandbox Code Playgroud)

我不熟悉[@]语法(虽然它似乎很清楚它想要发生什么),而且我找不到文档.谁能告诉我这是否是有效的jquery?

kar*_*m79 5

@是一个xpath选择器(具有属性),自jQuery 1.1.4以来已被弃用.只是把它留下来,或用伪选择器替换它们:

jQuery("#theForm")
.find("input:checked, input:text, option:selected, textarea")
.each(function() { ... });
Run Code Online (Sandbox Code Playgroud)

http://api.jquery.com/category/selectors/