Fmdpa Posted July 27, 2010 Share Posted July 27, 2010 <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 More sharing options...
justsomeguy Posted July 27, 2010 Share Posted July 27, 2010 You probably need to specify a left, top, bottom, or right property for the CSS. Are you getting any Javascript errors? Link to comment Share on other sites More sharing options...
Fmdpa Posted July 27, 2010 Author Share Posted July 27, 2010 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 More sharing options...
Fmdpa Posted July 27, 2010 Author Share Posted July 27, 2010 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 More sharing options...
Fmdpa Posted July 27, 2010 Author Share Posted July 27, 2010 BTW, how do you name and call a function in jQuery? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.