简体   繁体   中英

What happened to this selector syntax in jQuery?

I'm in the middle of fixing a jQuery plugin that is compatible with jQuery 1.1.3.1 and upgrading it so that it works with jQuery 1.6.2.

It has two CSS selector expressions that I assume are deprecated.

The first expression is:

$("li", _dropDownListJQuery).not("ul").not("span").not("[@dataType='optgroup']").each(

And it looks like the @datatype is no longer supported.

The second expression is:

var selectedDropDownListItemJQuery = jQuery("li[@dataValue='" + _originalElementJQuery.val() + "']");

Where

_originalElementJQuery.val()

Returns a stringified integer (eg "4").

Again it looks like the @dataValue is no longer supported.

Does anyone know any meaning preserving equivalents? Or has this plugin been forked on github?

That's an XPath Selector . They were deprecated in jQuery 1.2, eliminated in jQuery 1.3 and moved to a plugin . See the 1.3 release notes here . Going forward, jQuery selectors mostly support the CSS-selector style.

$("li[@dataValue='foo']") would become $("li[dataValue='foo']")

That plugin jquery.combobox has apparently been abandoned, as there hasn't been any further development.

Edited with BoltClock's correction.

Simply remove the @ symbol. The selector syntax now follows the css selectors (I think @ is from xpath).

You can also simplify your selector:

$("li:not([dataType='optgroup'])", _dropDownListJQuery)

Edit: confirmed, [@attrName=attrValue] is xpath

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM