Jump to content
Killersites Forums

Using custom attributes to associate elements


Recommended Posts

Just wondering how you guys do this --- say you have a script that adds a couple of links below every image on the page. How do you associate each set of links with their image?


I would typical use the "rel" attribute, as my understanding is that this is used to relate one element to another - though it is outside of the HTML 4.01 spec for most elements. So, if I had a link to display the image in a new window, the markup of that link would like this:

The javascript to open a new window would be attached to the element, but would use jQuery's .click() instead of an "onclick=" attribute. The "href=" would be there for compatibility's sake, just in case for some reason the browser let me insert the markup, but didn't recognize the onclick event properly.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...