jQuery Attributes - removeAttr() - attr() - prop()
Sử dụng hàm removeAttr() trong jquery
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script language="javascript" src="http://code.jquery.com/jquery-2.0.0.min.js"></script>
</head>
<body>
<input type="textbox" id="inputid" value="Giá trị input"/> Ăn <br/>
<input type="button" id="view1" value="Xóa Type"/>
<input type="button" id="view2" value="Thêm vào thuộc tính type = radio"/>
<script language="javascript">
// Bắt đầu code jquery
$(document).ready(function(){
// Xóa thuộc tính type khi click vào button 1
$('#view1').click(function(){
$('#inputid').removeAttr('value');
});
// Thêm vào thuộc tính type = radio
$('#view2').click(function(){
$('#inputid').attr('type', 'radio');
});
});
</script>
</body>
</html> jQuery Attributes Attr()
jQuery Attributes Prop()
PreviousjQuery Attributes - hasClass() - addclass() - removeclass()NextGiới thiệu và cấu hình cơ bản
Last updated