hasClassLike

码农软件 · 软件分类 · 其他jQuery插件 · 2020-01-10 08:14:09

软件介绍

hasClassLike allows the selection of elements based on pattern matching rather than specific names. This allows, for example, the passing of parameters to JavaScript via class names:

/* in js, such as in $(document).ready */
$("*")
        .hasClassLike("integer") /* filter some before using regexp */
        .hasClassLike(/^integer(?:Min(-?\d+))?(?:Max(-?\d+))?$/,function(m) {
                var min = m[1];
                var max = m[2];
                // ... install validating event handlers on $(this) ...
        });

<!-- in HTML -->
<input type="text" class="someOtherClass integerMin0"/>
<input type="text" class="integerMin-100Max100 someOtherClass"/>
<input type="text" class="someOtherClass integer yetAnotherClass"/>

There is an efficient simple substring match .hasClassLike(str) matched against the entire className of the element (that is, the space-separated list), useful for paring out unlikely elements. Then, a RegExp match with .hasClassLike(rx) comes back with the elements bearing at least one class matching a given pattern. Adding a callback function with .hasClassLike(rx,fn) makes it easy to modify or filter the found elements based on the match, which is passed to the callback function. If the callback returns false, the element is not included in the output (like with .filter).

本文地址:https://codercto.com/soft/d/23053.html

设计冲刺

设计冲刺

[美] 杰克·纳普、[美] 约翰·泽拉茨基、[美] 布拉登·科维茨 / 魏瑞莉、涂岩珺 / 浙江大学出版社 / 2016-8 / 58.00元

Uber / Nest Lab / Medium / Gmail / Chrome 成功助推无数现象级产品的谷歌风投团队(Google Ventures)首次现身著述 雄踞《纽约时报》/《华尔街日报》/ 亚马逊书店三大畅销榜榜首 当选Inc.杂志2016年必读商业佳作 ------------------- ※内容简介※ 谷歌风投投资的公司每天都会面对各种至关重......一起来看看 《设计冲刺》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具