mootools 选择器
A few weeks back, I showed you how to create a custom ":selected" pseudo selector for use in MooTools. It was just a small snippet but I've found it incredibly useful, as has been the ":checked" pseudo selector I've been using.
几周前,我向您展示了如何创建自定义的“:selected”伪选择器以用于MooTools。 这只是一个小片段,但我发现它非常有用,就像我一直使用的“:checked”伪选择器一样。
XHTML (The XHTML)
<input type="checkbox" name="mycheckbox" value="1" checked="checked" />
<input type="radio" name="mycheckbox" value="1" checked />
Above are examples of checked elements.
以上是选中元素的示例。
MooTools JavaScript (The MooTools JavaScript)
Selectors.Pseudo.checked = function(){
return ('input' == this.get('tag') && ('radio' == this.get('type') || 'checkbox' == this.get('type')) && this.checked);
};
Of course, you could always try to retrieve checked elements using "input[checked=checked]," but that code is case-sensitive and may not always return checked elements. What other pseudo selectors may be useful for MooTools?
当然,您始终可以尝试使用“ input [checked = checked]”来检索选中的元素,但是该代码区分大小写,并且不一定总是返回选中的元素。 其他哪些伪选择器可能对MooTools有用?
翻译自: https://davidwalsh.name/checked-pseudo-selector-mootools
mootools 选择器