ie8不支持伪类选择器的解决方案
2024-09-03 03:58:53
引用jQuery的插件jquery.pseudo.js
插件内容:
(function($){ var patterns = {
text: /^['"]?(.+?)["']?$/,
url: /^url\(["']?(.+?)['"]?\)$/
}; function clean(content) {
if(content && content.length) {
var text = content.match(patterns.text)[1],
url = text.match(patterns.url);
return url ? '<img src="' + url[1] + '" />': text;
}
} function inject(prop, elem, content) {
if(prop != 'after') prop = 'before';
if(content = clean(elem.currentStyle[prop])) {
$(elem)[prop == 'before' ? 'prepend' : 'append'](
$(document.createElement('span')).addClass(prop).html(content)
);
}
} $.pseudo = function(elem) {
inject('before', elem);
inject('after', elem);
elem.runtimeStyle.behavior = null;
}; if(document.createStyleSheet) {
var o = document.createStyleSheet(null, 0);
o.addRule('.dummy','display: static;');
o.cssText = 'html, head, head *, body, *.before, *.after, *.before *, *.after * { behavior: none; } * { behavior: expression($.pseudo(this)); }';
} })(jQuery); 引入插件后,即可在ie8中使用伪类选择器。
最新文章
- LINUX端口查看
- WARN: Establishing SSL connection without server&#39;s identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default i
- C#设计模式(7)——适配器模式(Adapter Pattern)
- Lucene 4.X 倒排索引原理与实现: (3) Term Dictionary和Index文件 (FST详细解析)
- 开启InnoDB每表一个独立的表空间
- wifidog编译到openwrt
- 动态规划(计数DP):HDU 5136 Yue Fei&#39;s Battle
- buffer busy waits
- Java小项目--坦克大战(version1.0)
- Codeforces Round #199 (Div. 2) B. Xenia and Spies
- Flink 1.3.2 Standalone模式安装
- CCF-201412-3-集合竞价
- np.array转换为list,嵌套的python list转成一个一维的python list
- Appium基于Python unittest自动化测试 &; 自动化测试框架 -- PO并生成html测试报告
- warn_alloc():page allocation failure问题分析
- OpenCV3编程入门-读书笔记2-core组件
- Glide 加载部分圆角图片
- (转)Linux SSH配置和禁止Root远程登陆设置
- 好汉两个半第十二季/全集Two and a Half Men迅雷下载
- GreenOpenPaint的实现(五)矩形框