返回介绍

:image Selector

发布于 2017-09-11 14:09:15 字数 1746 浏览 1181 评论 0 收藏 0

所属分类:选择器 > 表单 | 选择器 > jQuery 扩展

image selector

描述: 选择所有图像类型的元素。

  • 添加的版本: 1.0jQuery( ":image" )

:image 等价于 [type="image"]

Additional Notes(其他注意事项):

  • 因为 :image() 是 jQuery 延伸出来的一个选择器。 并且不是的CSS规范的一部分, 使用:image()查询不能充分利用原生DOM提供的querySelectorAll() 方法来提高性能。为了在现代浏览器上获得更佳的性能,请使用[type="image"]代替。

例子:

查找全部image inputs.

<!DOCTYPE html>
<html>
<head>
  <style>
  textarea { height:45px; }
  </style>
  <script src="http://cdn.bootcss.com/jquery/1.11.2/jquery.min.js"></script>
</head>
<body>
  <form>
  <input type="button" value="Input Button"/>
  <input type="checkbox" />
 
  <input type="file" />
  <input type="hidden" />
  <input type="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>
<div>
</div>
<script>
var input = $("input:image").css({background:"yellow", border:"3px red solid"});
$("div").text("For this type jQuery found " + input.length + ".")
        .css("color", "red");
$("form").submit(function () { return false; }); // so it won't submit
</script>
 
</body>
</html>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文