。selector属性的替代,现在它已在jQuery 1.9中删除

问题描述 投票:4回答:2

从jQuery 1.9开始,jQuery对象的.selector属性已被删除。 (确切地说,我对原因有些困惑)。我实际上在一些独特的场景中使用它,并且我知道我可以做其他事情来防止这种情况。 只是想知道是否有人知道从1.9开始的其他选择器吗?

$('#whatever').selector // (would of returned '#whatever')  

我需要。selector的一个例子是,我已经有一组[的复选框,并且我想在该组中查看哪个是[[checked:] >jsFiddle DEMO

var $test = $('input[name="test"]'); console.log( $test ); console.log( $(':checked', $test).attr('id') ); // returns --undefined-- console.log( 'now with .selector: '); console.log( $($test.selector + ':checked').attr('id') ); // returns correct


来自文档:
。jQuery对象上的.selector属性

jQuery上已弃用的.selector属性的剩余用途对象是支持不推荐使用的.live()事件。在1.9中,jQuery否由于链式方法需要更长的时间来维护此属性,因为.live()从未支持使用链接方法。不要在jQuery对象上使用.selector属性。 jQuery迁移插件不会尝试维护此属性。

从jQuery 1.9开始,jQuery对象的.selector属性已被删除。 (确切地说,我对原因有些困惑)。我实际上在一些独特的场景中使用它,并且我知道我可以做其他...
javascript jquery jquery-selectors deprecated jquery-1.9
2个回答
3
投票
需要

0
投票
© www.soinside.com 2019 - 2024. All rights reserved.