Jump to content

Help with JS and Jquery


Fmdpa

Recommended Posts

<html><head><script type="text/javascript" src="jquery.js"></script><script type="text/javascript">function overlay() {var overlay = document.createElement("div");overlay.setAttribute('id', 'overlay');document.body.appendChild(overlay);}</script><script type="text/javascript">$(function(){$('[rel=contact]').click(function(){$('#overlay').fadeTo(1000, 0.8);});});</script><style type="text/css">#overlay {position:fixed;background-color:black;width:100%;height:100%;display:none;}</style></head><body onload="overlay()"></body></html>

I have this code that is supposed to create a fixed div that is entirely black, and when any element with an attribute "rel='contact'", the black div will fadein to 0.8 opacity. In the first place, it doesn't seem to create the div in the createElement function. The $('[rel=contact]').click(function(){ doesn't seem to work either.EDIT: OOPS! I just noticed I messed up the style type attribute.

Link to comment
Share on other sites

No Javascript errors-just no response at all. I haven't validated it, if that's what you're asking. I just tried that too, but it doesn't fix the problem.

Link to comment
Share on other sites

Here we go:

<html><head><script type="text/javascript" src="jquery.js"></script><script type="text/javascript">function overlay() {var overlay = document.createElement("div");overlay.setAttribute('id', 'overlay');document.body.appendChild(overlay);}</script><script type="text/javascript">$(function(){$('[rel=contact]').click(function(){$('#overlay').fadeTo("normal", 0.8);});});</script><style type="text/css">#overlay {position:fixed;background-color:black;width:100%;height:100%;left:0px;top:0px;display:none;}</style></head><body onload="overlay()"><a href="#" rel="contact">contact</a></body></html>

Should've validated it. :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...