jQuery :image选择器
jQuery :image选择器是用来选择类型等于image的输入元素的。
语法:
$(":image")
参数: :enabled 选择器: 它用于选择HTML输入元素以改变其属性,例如背景颜色等。
示例 1:
<!DOCTYPE html>
<html>
<head>
<title>:image Selector</title>
<script src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
</script>
<script>
(document).ready(function () {
(":image").css("height", "50px");
});
</script>
</head>
<body>
<center>
<form action="#">
<h1>Welcome to GeeksforGeeks!</h1>
Image
<input type="image" src="logo.png"
width="31" height="30">
</form>
</center>
</body>
</html>
输出:
它改变了图像的高度。
示例 2:
<!DOCTYPE html>
<html>
<head>
<title>:image Selector</title>
<script src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
</script>
<script>
(document).ready(function () {
(":image").css("width", "150px");
});
</script>
</head>
<body>
<center>
<div style="background-color: #ffff94;">
<h1>Welcome to GeeksforGeeks!.</h1>
Image
<input type="image" src="logo.png"
width="31" height="30">
</div>
</center>
</body>
</html>
输出: