您的位置:首页 > Web前端 > JQuery

jQuery.attr ('class') 和 jQuery.attr ('className') 的区别

2012-07-27 09:39 441 查看
<div id="div1" class='A B C D'></div>


将div1里面class全部修改成E F G H

$('#div1').attr('class','E F G H');
//二者是一样的
$('#div1').attr('className','E F G H');


但是

document.getElementById('div1').className='E F G H' //正常
document.getElementById('div1').class='E F G H' //失败


jQuery里面

jQuery.props = {
"for": "htmlFor",
"class": "className",
readonly: "readOnly",
maxlength: "maxLength",
cellspacing: "cellSpacing",
rowspan: "rowSpan",
colspan: "colSpan",
tabindex: "tabIndex",
usemap: "useMap",
frameborder: "frameBorder"
};


  

name = notxml && jQuery.props[ name ] || name;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: