加载中...

:image


概述    image selector

返回值:Array<Element(s)>

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

  • V : 1.0jQuery( ":image" )

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

Additional Notes(其他注意事项):

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

示例

实例

匹配所有图像域

HTML 代码:
  1. <form>
  2. <input type="text" />
  3. <input type="checkbox" />
  4. <input type="radio" />
  5. <input type="image" />
  6. <input type="file" />
  7. <input type="submit" />
  8. <input type="reset" />
  9. <input type="password" />
  10. <input type="button" />
  11. <select><option/></select>
  12. <textarea></textarea>
  13. <button></button>
  14. </form>
jQuery 代码:
  1. $(":image")
结果:
  1. [ <input type="image" /> ]

实例

查找全部image inputs.

  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>image demo</title>
  6. <style>
  7. textarea {
  8. height: 45px;
  9. }
  10. </style>
  11. <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
  12. </head>
  13. <body>
  14. <form>
  15. <input type="button" value="Input Button">
  16. <input type="checkbox">
  17. <input type="file">
  18. <input type="hidden">
  19. <input type="image">
  20. <input type="password">
  21. <input type="radio">
  22. <input type="reset">
  23. <input type="submit">
  24. <input type="text">
  25. <select>
  26. <option>Option</option>
  27. </select>
  28. <textarea></textarea>
  29. <button>Button</button>
  30. </form>
  31. <div></div>
  32. <script>
  33. var input = $( "input:image" ).css({
  34. background:"yellow",
  35. border:"3px red solid"
  36. });
  37. $( "div" )
  38. .text( "For this type jQuery found " + input.length + "." )
  39. .css( "color", "red" );
  40. $( "form" ).submit(function( event ) {
  41. event.preventDefault();
  42. });
  43. </script>
  44. </body>
  45. </html>

运行一下


还没有评论.