Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here is a start point to play around with what you need (i hope) or just to understand:</p> <h2><a href="http://jsfiddle.net/roXon/Htgtg/" rel="nofollow">JSFIDDLE DEMO</a></h2> <pre><code>$("body").click(function(event) { // if you are not interested on 'body' himself use: $("body&gt;*") // QUESTIONS: var Q_qwer = 'Not a parent'; var Q_children = 'Not a children'; var Q_last = 'Not last'; var Q_first = 'Not first'; //# if ($(event.target).children().size() &gt; 0) { myChildren = $(event.target).children(); var Q_parent = myChildren[0].nodeName + ' (ID: ' + myChildren[0].id + ' || CLASS: ' + myChildren[0].className + ' )'; } if ($(event.target).parent().size() &gt; 0) { myParent = $(event.target).parent(); var Q_children = myParent[0].nodeName + ' (ID: ' + myParent[0].id + ' || CLASS: ' + myParent[0].className + ' )'; } if ($(event.target).is(':last-child')) { Q_last = 'LAST!' ; } if ($(event.target).is(':first-child')) { // or use: $(event.target).index() == 0 Q_first = 'FIRST!' ; } $("#log").html(' event.target: ' + event.target + ' &lt;br&gt; nodeName: ' + event.target.nodeName + ' , Tag: ' + event.target.tagName + ' &lt;br&gt; ID: ' + event.target.id + ' &lt;br&gt; Class: ' + event.target.className + ' &lt;br&gt; Href: ' + event.target.href + ' &lt;br&gt; Value: ' + event.target.value + ' &lt;br&gt; Children of: ' + Q_children + ' &lt;br&gt; Parent of: ' + Q_parent + ' (First children)' + ' &lt;br&gt; Last children?: ' + Q_last + ' &lt;br&gt; First children?: ' + Q_first + ' &lt;br&gt; .index( ' + $(event.target).index() + ')' + ' &lt;br&gt; .eq( ' + $(event.target).prevAll().length + ')' + ' &lt;br&gt; &lt;hr&gt;' + $(event.target).html() ); }); </code></pre> <p>Hope this helps! </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload