Another boring noob question ...
Function is called when i click on input fields called Hour or Minute
- <!-- table 24 hours -->
- <table width="33%" height="73" border="0" cellspacing="1" id="hour">
- <tr>
- <td>01</th>
- <td>02</th>
- <td>03</th>
- <td>04</th>
- <td>05</th>
- <td>06</th>
- <td>07</th>
- <td>08</th>
- <td>09</th>
- <td>10</th>
- <td>11</th>
- <td>12</th>
- </tr>
- <tr>
- <td height="34">13</td>
- <td>14</td>
- <td>15</td>
- <td>16</td>
- <td>17</td>
- <td>18</td>
- <td>19</td>
- <td>20</td>
- <td>21</td>
- <td>22</td>
- <td>23</td>
- <td>24</td>
- </tr>
- </table>
- <table width="214" height="54" border="0" cellpadding="1" cellspacing="2" id="min">
- <tr>
- <td>10</td>
- <td>15</td>
- <td>20</td>
- <td>25</td>
- <td>30</td>
- <td>35</td>
- <td>40</td>
- <td>45</td>
- <td>50</td>
- <td>55</td>
- <td>00
- </td>
- </tr>
- </table>
- <script>
- // that's looks nice ( for me :-) )
- $(document).ready(function(){
- $('td',this).mouseover(function(){
- $(this).addClass('hover');
- });
- $('td',this).mouseout(function(){
- $(this).removeClass('hover');
- });
- // but this looks ugly
- // BELOW LAME PART OF CODE :(
- // table HOUR ....
- $('#hour td').click(function() {
- $('#input_HOUR').val($(this).text()); // get the value and paste into INPUT field
- $('# hour').fadeOut();
- });
- // ... and table MIN ....
- $('#min td').click(function() {
- $('#input_MIN').val($(this).text()); // get the value and paste into INPUT field
- $('#minuty').fadeOut();
- });
- // whats clicked ... Hour - maybe MIN ?
- $('# input_HOUR ').click(function(){
- $('#hour').toggle();
- if($('#hour').is(':hidden')){
- $('#hour').fadein(1000);
- } else {
- $('#hour').fadeout(1000);
- }
- });
- // same code .... but different INPUT :/
- $('# input_MIN ').click(function(){
- $('#min').toggle();
- if($('#min').is(':hidden')){
- $('#min').fadein(1000);
- } else {
- $('#min').fadeout(1000);
- }
- });
- });
- </script>
My question is - how to do not DRY ( Hour and MIN ) ?