标签:元素 com 的区别 nbsp disable class 删除 prope html
$("#id").attr("checked",true);
//attr() 方法也允许您同时设置多个属性。
$("#id").attr({
        "href" : "http://www.runoob.com/jquery",
        "title" : "jQuery 教程"
    });
//也提供回调函数。回调函数有两个参数:被选元素列表中当前元素的下标,以及原始(旧的)值。然后以函数新值返回您希望使用的字符串。
$("#id").attr("href", function(i,origValue){
    return origValue + "/jquery"; 
  });
$(‘#id‘).removeAttr(‘checked‘);
//对于HTML元素本身就带有的固有属性,在处理时,使用prop方法。 //对于HTML元素我们自己自定义的DOM属性,在处理时,使用attr方法。 //property能够从attribute中得到同步。 //attribute不会同步property上的值。 //有true,false两个属性使用prop()(如‘checked‘,‘selected‘,‘disabled‘等)。
标签:元素 com 的区别 nbsp disable class 删除 prope html
原文地址:https://www.cnblogs.com/xxzb/p/12654905.html