06/04/2021, 14:49
Hàm :image Selector trong jQuery - JQuery API
image Selector sẽ lựa chọn tất cả các phần tử có type=image . Chú ý : Bởi vì :image là một Jquery extension và không phải là một phần thiết lập của CSS, các truy vấn sử dụng :image sẽ không thể phát huy hiệu quả của phương thức querySelectorAll() . Để đạt được hiệu quả cao nhất khi ...
image Selector sẽ lựa chọn tất cả các phần tử có type=image.
Chú ý: Bởi vì :image là một Jquery extension và không phải là một phần thiết lập của CSS, các truy vấn sử dụng :image sẽ không thể phát huy hiệu quả của phương thức querySelectorAll(). Để đạt được hiệu quả cao nhất khi sử dụng, sử dụng [type="image"] để thay thế.
Cú pháp
Cú pháp
jQuery( ":image" )
Ví dụ
Tìm kiếm phần tử có type=image và đổi màu cho chúng:
Code
RUN
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>all demo</title>
<script src="https://Zaidap.com.net/cnd/js/jquery/jquery-3.2.1.min.js"></script>
</head>
<body>
<h1>Học lập trình miễn phí tại Zaidap.com.net</h1>
<form>
<input type="button" value="Input Button">
<input type="checkbox">
<input type="file">
<input type="hidden">
<input type="image" value="Đây là thẻ có type bằng image">
<input type="password">
<input type="radio">
<input type="reset">
<input type="submit">
<input type="text">
<select>
<option>Option</option>
</select>
<textarea></textarea>
<button>Button</button>
</form>
<button onclick="myFunction()">Click vào đây để xem kết quả</button>
<script>
function myFunction(){
$( "input:image" ).css( "background", "red" );
}
</script>
</body>
</html>Kết quả:
Tham khảo: jquery.com
Nguồn: Zaidap.com.net