mootools 选择器_为MooTools 1.2创建自定义的“:checked”伪选择器

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 选择器

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值