简体   繁体   English

相当于jQuery的原型选择器

[英]prototype selector equivalent to jQuery

How can I select the popupwindow of the popup-lightbox div? 如何选择popup-lightbox div的popupwindow

in jQuery, it's be something like $('div#popup-lightbox #popupwindow'). 在jQuery中,它类似于$('div#popup-lightbox #popupwindow')。 Unfortunatly, in Prototype, it's not that easy... anyone can help me? 不幸的是,在Prototype中,这并不容易……任何人都可以帮助我? thanks! 谢谢!

<div id="popup-lightbox" class="popup">
    <div id="popupoverlay"></div>
    <div id="popupdiv">
        <div id="popupwindow"></div>
    </div>
</div>

<div id="popup-modal" class="popup">
    <div id="popupoverlay"></div>
    <div id="modaldiv">
        <div id="popupwindow">
            <div id="modalint">Your changes have not been saved.</div>
        </div>
    </div>
</div>

Use the bling-bling http://api.prototypejs.org/language/dollardollar/ 使用bling-bling http://api.prototypejs.org/language/dollardollar/

$$('#popup_lightbox #popup_window') (also, you are not using ids properly, like desau and fantactuka said) $$('#popup_lightbox #popup_window') (另外,您没有正确使用ID,例如desau和fantactuka所说的)

First up, you're using ID attributes incorrectly. 首先,您使用的ID属性不正确。 According to the W3C specification, ID attributes are supposed to be unique across the document. 根据W3C规范,ID属性在整个文档中应该是唯一的。

That aside, the prototype selection syntax is slightly different from jQuery: 除此之外,原型选择语法与jQuery略有不同:

$("popup-lightbox").select("#popupwindow")[0];

Actually since id should be uniq at the page I'm not sure that it makes sense to use complex selector. 实际上,由于id在页面上应该是唯一的,所以我不确定使用复杂的选择器是否有意义。 Why not just $('popupwindow')? 为什么不只是$('popupwindow')?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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