好的,我有一行 jQuery 代码,我需要将其转换为使用 Prototype。
$(document).ready(function(){
if(navigator.userAgent.indexOf('Chrome')!=-1)
{
/* Applying a special chrome curosor,
as it fails to render completely blank curosrs. */
zoom.addClass('chrome');
}
});
zoom 是类名,如果检测到 chrome,我想将类 chrome 添加到其中。
到目前为止,对于原型我有这个:
document.observe("dom:loaded", function() {
Object.prototype.addClass = function(className) {
if (!this.hasClass(className)) { //if the class isn't there already
this.className += (' ' + className); //append it to the end of the class list
}
}
});
但不幸的是,这是我通过谷歌搜索所能得到的。
有人有解决方案吗?