所以我使用了一个jQuery插件模板,不幸的是它不能在IE8和IE兼容模式下工作。我的jQuery插件与IE8完全不兼容吗?
我不知道我写他们的方式是兼容还是如果我只是失去了一些东西?
HTML:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SuperHero Demo</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="Scripts/SuperSelect.js"></script>
</head>
<body>
<div class="test" style="border:1px solid #000;">
<p>Hello World!</p>
</div>
<div>
<p>Sup World</p>
</div>
<script>
$('.test').superHero({
});
</script>
</body>
</html>
SCRIPT:
// Utility
if (typeof Object.create !== 'function') {
Object.create = function(obj) {
function F(){};
F.prototype = obj;
return new F();
};
}
(function($, window, document, undefined) {
var Super = {
init: function(options, elem) {
var self = this;
self.elem = elem;
self.$elem = $(elem);
if (typeof options === 'string') {
self.duration = options;
} else {
// object was passed
self.duration = options.duration;
}
self.options = $.extend({}, $.fn.superHero.options, options);
self.replaceSelect();
},
replaceSelect: function(duration) {
var self = this;
$('.test').hide();
$('.test').after('<select><option value="volvo">Volvo</option><option value="saab">Saab</option><option value="mercedes">Mercedes</option><option value="audi">Audi</option></select>');
},
};
$.fn.superHero = function(options){
return this.each(function() {
var hero = Object.create(Super);
hero.init(options, this);
$.data(this, 'superHero', hero);
});
};
$.fn.superHero.options = {
duration: 5000, //Milliseconds that each slide remains on screen. Default is 5 seconds.
transition: 'fade', //How will the slides trascend?
};
})(jQuery, window, document);
http://jsfiddle.net/userdude/QWhPL/1/
我说这是行12.什么“行不通”那么多的描述,它必须是12行。';'' –
你指的是:init:function(options,elem){? –
我指的是你让我们猜测什么“不行”应该是什么意思,甚至是什么“行得通”。 –