Highlighting an element as it is hovered over (like inspect element in FireBug)
I'm trying to get the same functionality that firebug has in it's inspect element in where as you mouseover things it hightlights it and when you click an element it unbinds both mouseover and click
- .one('click', function(){unbind...})
Then I want to display the absolute path to that element like: html > body > ul > ul > li > ul > li > a > font
Anyway heres my basic code so far
- (function($)
- {
- $('<style type="text/css">.qwertymk{border: 1px black solid}</style>')
- .appendTo('head');
-
- function aimedAt(evt)
- {
- var $targ = $(evt.originalEvent.explicitOriginalTarget); //This worked when it was a click event
- if ($targ[0].nodeType == Node.TEXT_NODE)//jQuery considers a TEXT_NODE
- $targ = $targ.parent(); //just a property of it's parent
- return $targ;
- }
- /*$(document).bind('click', function(e)
- {
- var $el = aimedAt(e);
- $el.css('border', '1px black solid');
- console.log($el);
- e.preventDefault();
- });*/
- $(document).hover(function(e)
- {
- var $el = aimedAt(e);
- $el.toggleClass('qwertymk');
- });
- /*$(document).one('click', function()
- {
- });*/
- })(jQuery)