Jump to content
iwato

Using the "rel" Attribute as a jQuery Trigger

Recommended Posts

Background: According to the W3Schools webpage the "rel" attribute should only be used with the <a> tag when the "href" attribute is present. In contrast, the "rel" attribute is used in jQuery Tools with the <img> element and the "src" attribute. There is an obvious contradiction here. Question One: Just how flexible is the "rel" attribute? Can it be used with any HTML element that refers to a link? If not, just what are its exact limitations? Question Two: Is it possible to reconfigure jQuery Tools dynamically so that an attribute other than the "rel" attribute can be used in the absence of an HTML tag with a linked document? How would one go about it? A former W3Schools regular,Roddy (Kiusau) :Pleased:

Share this post


Link to post
Share on other sites

Any attribute that is created by javascript/jquery does not apply, as validation can't read JS generated attributes, in fact you could create any attribute name Rumpelstiltskin="any data", instead of rel to hold and retrieve a value.

  • Like 1

Share this post


Link to post
Share on other sites

Consider the below script taken from the jQuery page suggested by Deirdre's Dad. The script is succinct and easy to follow. I would like to know, if my interpretation of the second <script> tag is correct. <!DOCTYPE html><html><head> <style> div { color:blue; } span { color:red; } </style> <script src="http://code.jquery.com/jquery-latest.js"></script></head><body> <div> The values stored were <span></span> and <span></span> </div><script>$("div").data("test", { first: 16, last: "pizza!" });$("span:first").text($("div").data("test").first);$("span:last").text($("div").data("test").last);</script> </body></html INTERPRETATION1) Create an attribute called "test" with an object-value consisting of two properties called "first" and "last".2) Assign this attribute to all <div> tags and further assign the values "16" and "pizza", respectively, to these two properties. 3) Find the first <span> tag of the document and enter the value of the first property of the newly created object "test".4) Find the last <span> tag of the document and enter the value of the second property of the newly created object "test". Have I understood properly? Roddy :Pleased:

Edited by iwato

Share this post


Link to post
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.

Guest
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.

Loading...

×
×
  • Create New...