[ jquery 方法 removeAttr(name) | removeProp(name) ] 此方法用来删除对应的由.attr() | .prop()方法设置的属性集

用来删除由.attr() | .prop()方法设置的属性集:

  随着一些内置属性的DOM元素或window对象,如果试图将删除该属性,浏览器可能会产生错误。jQuery第一次分配undefined值的属性,而忽略了浏览器生成的任何错误

实例:

<!DOCTYPE html>
<html lang='zh-cn'>
<head>
<title>Insert you title</title>
<meta http-equiv='description' content='this is my page'>
<meta http-equiv='keywords' content='keyword1,keyword2,keyword3'>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- <script type='text/javascript' src='./js/jquery-3.0.0.js'></script> -->
<script type='text/javascript' src='./js/jquery-1.12.1.min.js'></script>
<style type='text/css'>
   input{font:400 13px/20px 'Courier New';color:#000;}
</style>
<script type='text/javascript'>
    $(function(){
        $('user').prop('autocomplete','on');
        $('#user').removeProp('autocomplete');
        $('#user').attr('style','background:#EEE;outline:none');
        $('#user').removeAttr('style');
    });
</script>
</head>
<body>
   <input type='text' id='user' required="required"/>
</body>
</html>

 

posted @ 2016-06-22 00:13  窗棂  Views(1352)  Comments(0Edit  收藏  举报