removeAttr(name) trong jQuery
Miêu tả
Phương thức removeAttr(name) trong jQuery gỡ bỏ một thuộc tính từ mỗi phần tử được so khớp.
Cú pháp
Sau đây là cú pháp cho removeAttr(name) trong jQuery:
selector.removeAttr( name )
Tham số
Dưới đây miêu tả chi tiết về các tham số được sử dụng trong phương thức removeAttr(name) trong jQuery:
name − Tên của thuộc tính để bị gỡ bỏ.
Ví dụ
Sau đây là ví dụ đơn giản minh họa cách sử dụng của phương thức removeAttr(name) trong jQuery. Ví dụ này sẽ gỡ bỏ border từ mỗi bảng.
<html>
<head>
<title>The Selecter Example</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
</script>
<script type="text/javascript" language="javascript">
$(document).ready(function() {
$("table").removeAttr("border");
});
</script>
</head>
<body>
<table border="2">
<tr><td>This is first table</td></tr>
</table>
<table border="3">
<tr><td>This is second table</td></tr>
</table>
<table border="4">
<tr><td>This is third table</td></tr>
</table>
</body>
</html>
Nó sẽ cho kết quả:
Công cụ giáo viên (2048.VN)
Tạo- trộn đề thi miễn phí từ file PDF, Word, Giao bài nhanh chóng, Hoàn toàn Free
Các bài học jQuery khác tại VietJack:
Dành cho bạn
Công cụ giáo viên
- Tạo đề online từ PDF / Word
- Trộn nhiều mã đề, in Offline
- Giao bài online, Quản lí lớp học

