Событие ondblclick

Internet Explorer Chrome Opera Safari Firefox
6.0 7.0 8.0 9.0 10.0 11.0 12.0 13.0 9.2 9.6 10.0 11.0 2.0 3.1 4.0 5.0 3.0 4.0 5.0 6.0

Описание

Событие ondblclick возникает при двойном щелчке левой кнопкой мыши на элементе.

Синтаксис

ondblclick="скрипт"

Значения

Код скрипта

Значение по умолчанию

Нет.

Применяется к тегам

<a>, <abbr>, <acronym>, <address>, <applet>, <area>, <b>, <basefont>, <bdo> <bgsound>, <big>, <blockquote>, <body>, <br>, <button>, <caption>, <center>, <cite>, <code>, <col>, <colgroup>, <dd>, <del>, <dfn>, <dir>, <div>, <dl>, <dt>, <em>, <embed>, <fieldset>, <font>, <form>, <frame>, <h1>, <h2>, <h3>, <h4>, <h5>, <h6>, <hr>, <i>, <iframe>, <img>, <input>, <ins>, <isindex>, <kbd>, <label>, <legend>, <li>, <link>, <map>, <marquee>, <menu>, <nobr>, <object>, <ol>, <option>, <p>, <plaintext>, <pre>, <q>, <s>, <samp>, <select>, <small>, <span>, <strike>, <strong>, <sub>, <sup>, <table>, <tbody>, <td>, <textarea>, <tfoot>, <th>, <thead>, <tr>, <tt>, <u>, <ul>, <var>, <wbr>, <xmp>

Пример

HTML 4.01IE 7IE 8IE 9Cr 13Op 11Sa 5Fx 6

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>Событие ondblclick</title>
  <style type="text/css">
   div {
    height: 200px; /* Высота слоя */
    background: #f0f0f0; /* */
    padding: 5px; /* Поля вокруг текста */
    border: 1px solid #333; /* Параметры рамки */
   }
  </style>
  <script type="text/javascript">
   var color = 0;
   function colorDiv() {
    if (color) {
      document.getElementById("layer").style.background = "#f0f0f0";
      color = 0;
    }
    else {
      document.getElementById("layer").style.background = "#fc0";
      color = 1;
    }
   }
  </script>
 </head> 
 <body>
  <p>Дважды щелкните в этом поле для изменения цвета фона.</p>
  <div id="layer" ondblclick="colorDiv()">
  </div>
 </body>
</html>

В данном примере при двойном щелчке мышью внутри слоя, фон слоя меняет свой цвет с серого на оранжевый и наоборот.

Если вам понравились материалы сайта, вы можете поддержать сайт, купив справочник по HTML в формате CHM, в виде набора HTML-файлов или в формате PDF за 30 р.