Skip to content

Instantly share code, notes, and snippets.

@chungan1997
Created May 21, 2018 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chungan1997/472152b4264536e7f56456804f25075c to your computer and use it in GitHub Desktop.
Save chungan1997/472152b4264536e7f56456804f25075c to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("div").css( {"font-size" : "100px"});
});
});
</script>
</head>
<body>
<p>Sử dụng Jquery đặt lại font-size cho thẻ div là 100px và chuyển thẻ div sang trái 200px.
</p>
<div style="background:#98bf21;height:200px;width:600px;">Hello World</div>
<button > Đổi định dạng</button>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("span").mouseover(function(){
$(this).hide();
});
$("#text").keypress(function(){
$(this).hide();
});
});
</script>
</head>
<body>
<p>Sử dụng jquery xử lý sự kiện khi nhập 1 ký tự vào ô nhập thì ô nhập biến mất
và khi di chuyển chuột qua thẻ span thì thẻ span biến mất</p>
<input id = text name = text type="text" value="" size="40">
<span>If you mouse over me, I will disappear.</span><br>
<span>If you mouse over me, I will disappear.</span>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("#demo").hide();
$(".test").hide();
});
});
</script>
</head>
<body>
<span> Sử dụng jquery ẩn đi tất cả các thẻ có class là test và các thẻ có id là demo
<h2 class="test">This is a heading</h2>
<p class="test">This is a paragraph.</p>
<p>This is another paragraph.</p>
<p id="demo">This is a demo p.</p>
<button> Ẩn tất cả</button>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment