用css selectors 绑定html tag的行为
等同于下面的语句:
<li>
<a onclick="this.parentNode.removeChild(this)" href="#">
Click me to delete me
</a>
</li>
这里用到了Ben Nolan 在
http://bennolan.com/behaviour/ 上发布的Behaviour.js .
1 . html文件如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Example</title>
<script type="text/javascript" src="behavior.js"></script>
<script type="text/javascript" src="example.js"></script>
</head>
<body>
<ul id="example">
<li>
<a href="/delete">Click me to delete me</a>
</li>
</ul>
</body>
</html>
2. example.js文件如下:
var myrules = {
'#example li' : function(el){
el.onclick = function(){
this.parentNode.removeChild(this);
}
}
};
Behaviour.register(myrules);
结论: 这样的结果会让view层更清洁.
[附]behavior.js:
http://bennolan.com/behaviour/behaviour.js
分享到:
- 2006-11-05 17:08
- 浏览 4013
- 评论(0)
- 论坛回复 / 浏览 (0 / 2606)
- 查看更多
相关推荐
Exactly how does the “cascade” in Cascading Style Sheets work?... Why wait when you can learn how to use selectors and other key CSS 3 features right away?,解压密码 share.weimo.info
https://www.vogella.com/tutorials/Eclipse4CSS/article.html#:~:text=%20Eclipse%204%20CSS%20Styling-%20Tutorial%20%201,attributes%20and%20selectors%0AThe%20CSS%20attributes%20for...%20More%20
From there, you’ll get to play with CSS3’s new selectors so you can learn how to apply styles to elements without adding extra markup to your content. Then we’ll explore HTML’s audio and video ...
Learning Web Design: A Beginner’s Guide to HTML, CSS, JavaScript, and Web Graphics By 作者: Jennifer Robbins ISBN-10 书号: 1491960205 ISBN-13 书号: 9781491960202 Edition 版本: 5 出版日期: 2018-05-21...
Desktop-only websites just aren’t ...Learn how to use the latest features of CSS including custom fonts, nth-child selectors (and some CSS4 selectors), CSS custom properties (variables), and CSS calc
根据提供的文件信息,这里将对CSS选择器进行详细介绍。CSS(层叠样式表)是一种用于定义HTML或XML文档中元素的外观的语言。选择器是CSS的核心部分,它们定义了哪些HTML元素应该应用样式规则。 ### CSS选择器速查表 ...
How to use the CSS color property to change colors How to modify text and font of a website How to create navigation bars How to create gorgeous looking tables to display your data
HtmlAgilityPack.CssSelectors.NetCore· 使用的NetStandard版本 安装 Install-Package HtmlAgilityPack.CssSelectors.NetCore 用法 var doc = new HtmlAgilityPack . HtmlDocument (); doc . Load ( new ...
You’ll draw with the Canvas and SVG, do simple animations with pure CSS, work with advanced CSS selectors, and make audio and video play natively. You’ll bring your web apps to the next level as ...
postcss-icss-selectors, 用于本地范围类和id的css模块的PostCSS插件 postcss-icss-selectors 用于本地范围类和id的css模块的PostCSS插件用法postcss([ require('postcss-icss-selectors')(options) ])有关环
The CSS Quick Syntax Reference is a 150-page syntax reference to the Cascading Style Sheet specification and style sheet language. It presents the essentials of CSS in a well-organized format that can...
CSS3 is the latest version of Cascading Style Sheets, the language that in the hands of a skilled designer turns the ugly duckling of unadorned HTML into the gracious swan of a sophisticated web page....
Learn how to use the latest features of CSS including custom fonts, nth-child selectors (and some CSS4 selectors), CSS custom properties (variables), and CSS calc Make a mobile website using jQuery ...
CSS is the preferred technology to design modern web pages. Although CSS is often perceived as a simple language, applying modern styles to web pages with CSS and maintaining the code for larger ...
5. **选择器增强**:CSS3 扩展了选择器的功能,提供了更多用于定位元素的方法,如子选择器(Child Selectors)、相邻兄弟选择器(Adjacent Sibling Selectors)等。 #### 三、实际应用中的挑战与解决方案 尽管 ...
list-selectors 可以列出你在 CSS 使用的 selector,它可作为一个独立的函数,CLI, 或者 PostCSS 插件。使用示例:var listSelectors = require('list-selectors'); listSelectors( ['style/**/*.css', '!...
学习资源:《Nailing Browser Support in CSS3 and HTML5: Invaluable Resources to Use Today》、《Browser Support for CSS3: What’s the Current Status?》和《The Importance of Cross Browser Compatibility:...
在 HTML5 中,JavaScript 可以通过使用 CSS Selectors 来选择和操作 HTML 元素的样式。CSS Selectors 是一种选择器语法,用于选择 HTML 元素,以便对其进行样式设置或其他操作。JavaScript 可以通过使用 CSS ...
npm install --save-dev postcss postcss-combine-duplicated-selectors# oryarn add --dev postcss postcss-combine-duplicated-selectors使用PostCSS JS API 'use strict' ;const fs = require ( 'fs' ) ;const ...