clickOnParent: Click on the Parent of a Link
Sometimes you just can't avoid the situation where a design requires a large area to be clickable but still have block-layout inside. Of course the "A" elements shouldn't just be placed around large swath of block-elements, lest it ruin the layout.
This "classBehaviour" function allows the hyperlink to be moved from a link to the containing element.
Clickable Table Rows
A typical application of this script are table-rows. The hyperlinks in the "th" elements below are moved to the entire "TR", so the row becomes a link to click on.
Lorem |
Ipsum |
Dolor |
|---|---|---|
| Total | 6 | 9 |
| 5 | 0 | |
| Yahoo | 1 | 4 |
| Firefox | 3 | 2 |
| Opera | 4 | 1 |
| Apple | 2 | 3 |
| W3C | 0 | 5 |
The "parent_2" class name tells the script to move the link up two levels, from the "A" to the "TR" skipping the "TH"-element.
Clickable Article Contents
A design that demands the whole article text to be clickable is usually a nightmare, almost demanding an "A" element with some nasty markup on "SPAN" elements and "STRONG" used for heading. The trouble is that it's much more semantically correct to use "H1, H2, H3", and "P" elements around the summary contents.
-
Bigger
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
-
Copy
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
-
Create Link
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
-
Delete
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
-
Insert Image
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
-
Insert
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
-
Paste
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
-
Toggle HTML
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
-
Toggle Text
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
-
Undo
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
-
Unlink
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
In this case the script allows the "A" to be kept from having to envelop the block-elements.
Required Files
-
jQuery Addon Script: jquery.classbehaviours.clickonparent.js
- Prerequisite Script: jquery.classbehaviours.js
- Example Markup: clickOnParent.html
- Example Stylesheet: clickOnParent.css
Comments on this Article