Bug Tracker

Changes between Version 1 and Version 2 of Ticket #7220, comment 3


Ignore:
Timestamp:
Oct 21, 2010, 9:22:19 PM (11 years ago)
Author:
cowboy
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #7220, comment 3

    v1 v2  
    22
    33{{{
     4// Log the selector used to select elements to each selected element,
     5// otherwise to the body. Hover over logged selectors to highlight
     6// stuff all fancy-like (note: don't select SPAN elements because this
     7// creates them all over the place!) - Cowboy
     8
    49$.fn.logSelector = function() {
    5     var elem = this.length ? this : $('body');
    6     elem.append( this.selector + ' [' + this.length + ']<br/>' );
     10    var elems = $( '<span>' + this.selector + ' [' + this.length + ']</span>' )
     11        .appendTo( this.length ? this : 'body' );
     12   
     13    this.length && elems.hover(function(e){
     14        elems.parent().andSelf().toggleClass( 'hover', e.type === 'mouseenter' );
     15    });
     16   
    717    return this;
    818};