Love beautiful code? We do too.
.removeAttr(): Loại bỏ các thuộc tính (attr) có bên trong thành phần.
Đã được thêm vào từ phiên bản 1.0
.removeAttr('Tên thuộc tính')
$('div').removeAttr('class');
Html viết:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Tiêu đề</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(function(){
$('.test').removeAttr('class');
});
</script>
</head>
<body>
<div id="remove" class="test">Thành phần div</div>
</body>
</html>
Hiển thị trình duyệt:
Ta thấy thuộc tính class đã bị loại bỏ khỏi thành phần div.
Hoclaptrinh.vn © 2017
From Coder With
Unpublished comment
Viết câu trả lời