这是我在SO上的第一篇文章:-)
我在将MooTools转换为CSS类时遇到了问题。我很确定我已经遵循了文档和演示,但是当我调用myElement.morph('.hover')
时,它不会变成.hover
类。我的设置如下:
index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="style.css" />
<script src='mootools.js' type="text/javascript"></script>
<script src='hover.js' type="text/javascript"></script>
</head>
<body>
<div class="btn"></div>
</body>
</html>
hover.js:
window.addEvent('domready', function() {
var myElement = $$('.btn')[0];
myElement.morph('.hover'); // This doesn't work
//myElement.morph({ 'background-color': '#009' }); // This works
//myElement.set('class', 'hover'); // This also works
});
style.css:
.btn {
width: 200px;
height: 100px;
background-color: #999;
}
.hover {
width: 200px;
height: 100px;
background-color: #009;
}
我找到了someone with a related problem,但.hover
是我selector...so的全名,我被难住了。
提前感谢您的帮助!
发布于 2011-02-23 11:24:26
这不起作用,因为有一个错误:https://mootools.lighthouseapp.com/projects/2706/tickets/1063-no-class-morphing-with-13-no-compat
修复的里程碑: 1.3.1 (所以很快)-或者你可以从github上的1.3.1分支获得Element.Style.js的补丁。
发布于 2011-02-23 01:20:22
Mootools 1.3核心似乎有一个错误(非compat)。
如果在above Fiddle中选择非兼容版本,则会出现以下错误:Element.Styles.each is not a function
。
解决方案可能是切换到MooTools Core 1.3 with compatibility。
(从1.3开始,Element
类中的Styles
属性似乎不再存在)
发布于 2011-02-23 11:15:26
就我的两分钱。它不应该是这样的吗:http://jsfiddle.net/3wKhN/
https://stackoverflow.com/questions/5085883
复制相似问题