المحدد ‎‎‎:reset‎‎ في jQuery

من موسوعة حسوب
اذهب إلى التنقل اذهب إلى البحث
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

المحدد ‎:reset

الوصف

يحدِّد جميع عناصر الإدخال <input> ذات النوع reset.

‎jQuery( ":reset" )‎

أُضيف مع الإصدار: 1.0.

المحدِّد ‎$( ":reset" )‎ يكافئ ‎$( "[type=reset]" )‎.

ملاحظات إضافية

لمَّا كان المحدِّد ‎:reset هو ملحق في مكتبة jQuery  وليس جزءًا من مواصفة CSS، فإنَّ الاستعلامات التي تستعمل ‎:reset لا يمكنها الاستفادة من سرعة الأداء الذي يوفره تابع DOM الأصلي querySelectorAll()‎. للحصول على أداء أفضل في المتصفحات الحديثة، حدِّد العناصر باستعمال محدِّدات CSS الصرفة (pure) ثمَّ استعمل التابع ‎.filter(" :reset ")‎.

أمثلة

إيجاد جميع العناصر <input> التي من النوع reset:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>reset مثالٌ عن استعمال المحدد</title>
  <style>
  textarea {
    height: 45px;
  }
  </style>
  <script src="https://code.jquery.com/jquery-1.10.2.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>
  </select>
  <textarea></textarea>
  <button>زر</button>
</form>
<div></div>
 
<script>
var input = $( "input:reset" ).css({
  background: "yellow",
  border: "3px red solid"
});
$( "div" )
  .text( "For this type jQuery found " + input.length + "." )
  .css( "color", "red" );
 
// Prevent form submission
$( "form" ).submit(function( event ) {
  event.preventDefault();
});
</script>
 
</body>
</html>

مصادر