简体   繁体   中英

How to convert $('id1', 'id2') in Prototype JS to jQuery?

I have var something = $('id1', 'id2');

What is the equivalent in jQuery?

The equivalent is var something = $('#id1, #id2'); . This will produce a jQuery object with both objects.

On the other hand, in jQuery the second argument of the constructor is for scope, so $('#id1', '#id2') would give you the element for #id1 that was inside of the #id2 element. It is equivalent to $('#id2').find('#id1') which is not the same as the combination you were looking for.

jQuery uses css selectors in order to target elements, and almost all of the native css selectors will work as an argument.

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