SelectorListener
Listen for CSS selector rule matches at document or element level
Install / Use
/learn @csuwildcat/SelectorListenerREADME
SelectorListener
Provides the following document/element methods to enable listening for CSS selector rule matches:
Document-wide Selector Listeners
var oneTwoThree = function(){
alert('Listening for complex element sequences is easy as 1, 2, 3!');
};
document.addSelectorListener('.one + .two + .three', oneTwoThree);
document.removeSelectorListener('.one + .two + .three', oneTwoThree);
Selector Listeners on Individual Elements
var foo = document.getElementById('foo');
foo.addSelectorListener('.one + .two + .three', oneTwoThree);
foo.removeSelectorListener('.one + .two + .three', oneTwoThree);
Support for At-Rules
document.addSelectorListener(['@media (min-width: 500px)', 'h2:target'], someFn);
Interesting Examples:
// Listening for attribute value matches? Child's play.
document.addSelectorListener('.foo[bar="boom"]', function(){ ... });
// Listen for when elements are emptied of their children
document.addSelectorListener('*:empty', function(){ ... });
// How about a more performant way to listen for custom tooltip nodes document wide?
document.addSelectorListener('.tooltip:hover', function(){ ... });
// Act on inputs the moment any field fails native validation pattern logic
document.addSelectorListener('*:invalid', function(){ ... });
// Working with HTML5 sliders just got even easier
document.querySelector('#RandomForm').addSelectorListener('slider:out-of-range', function(){
alert('Your slider value is now out of range! Oh noes!');
});
Related Skills
node-connect
342.5kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
85.3kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
342.5kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
342.5kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
