Thứ Tư, 25 tháng 6, 2014

Tìm kiếm một thẻ nằm trong một thẻ xác định sử dụng jquery

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>find demo</title>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<p><span>Hello</span>, how are you?</p>
<p>Me? I'm <span>good</span>.</p>
<script>
// $( "p" ) lấy thẻ p
// $( "p" ).find( "span" ) tìm lấy thẻ span trong thẻ p
// $( "p" ).find( "span" ).css( "color", "red" );  định dạng đỏ cho chữ ở trong thẻ span
$( "p" ).find( "span" ).css( "color", "red" );
</script>
</body>

Không có nhận xét nào: