Skip to content

Instantly share code, notes, and snippets.

@rnmp
Created August 29, 2011 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rnmp/1178710 to your computer and use it in GitHub Desktop.
Save rnmp/1178710 to your computer and use it in GitHub Desktop.
$(document).bind('keydown', 'h', function() {
$hex.toggle(function() {
$(this).hide();
}, function() {
$(this).show();
});
});
@xenda
Copy link

xenda commented Aug 29, 2011

Yo aplicaría el toggle al this del document:

 $(document).bind(....., function(){
  $(this).toggle(function(){
      $hex.hide();
     },function(){
      $hex.show();
    })
 } 

@xenda
Copy link

xenda commented Aug 29, 2011

Aunque depende de qué sea $hex, no lo he revisado :D

@rnmp
Copy link
Author

rnmp commented Aug 29, 2011

$(function(){
  var $body = $('body'), 
      $color = $('.color'),
      $hex = $('.hex'),
      $prefix = $('.prefix'),
      $input_id = 'clipboard_handler';
  $body.prepend('<input id="'+$input_id+'" disabled type="text" />');
  $color.hover(function() {
    var $hex_code = $('.hex', this).text();
    $('#'+$input_id).val($hex_code).select();
  });
  $hex.each(function(){
    // This clears the HEX value provided
    $(this).text($(this).text().replace('#',''));
    $(this).prepend('<span class="prefix" />');
    $('.prefix', this).text('#');
  });

  $(document).bind('keydown', 'h', function(){
    $(this).toggle(function(){
      $hex.hide();
    }, function(){
      $hex.show();
    })
  });
});

@rnmp
Copy link
Author

rnmp commented Aug 29, 2011

Así es el código completo, implementando tu solución. Que no funciona. D:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment