been messing around with Jquery, wondering if I have an error with this small peice of code, maybe the css function?
here's what it looks like in plain JS that works.Code:$('#wrap').mouseover(function (){ $(this).css({ 'background-color':'#FFFFFF', 'filter':'alpha(opacity=100)', 'opacity ':'1.0' }); });
Code:function mouseOver(){ var oWrap = document.getElementById('wrap'); oWrap.style.backgroundColor = "#FFFFFF"; oWrap.style.filter = "alpha(opacity=100)"; oWrap.style.opacity = 1.0; }
Results 1 to 4 of 4
Thread: Do I have a syntax error?
- 31 Jul. 2011 09:52pm #1
Do I have a syntax error?
- 31 Jul. 2011 11:18pm #2
The jQuery itself is fine. Just a couple of things to watch out for:
1. You can only execute most jQuery code after the DOM has fully loaded. Almost all of your code should go in:
Code:$(document).ready(function() { // code here });
- 01 Aug. 2011 12:56am #3
Yeah, I have it in the ready, that's a given. Though it's still not working correctly. I'll look more into later, I'm too excited to care anymore.
I will never go back to traditonal JS after learning this, I've turned a highlighting function into something as small as this! I'll continue looking over Jquery and hopefully, I can release something.
Code:$(document).ready(function() { $('#blue').hover(function() { $(this).toggleClass("highlight"); }); });
Last edited by HTML; 01 Aug. 2011 at 12:58am.
- 01 Aug. 2011 01:17am #4
That snippet of Javascript is fine. I just tested it.
If it still isn't working, I'd wager there's some invalid syntax elsewhere that's causing it all to break. Might be easier if you pasted/PMed me the entire page's source code.
And yes, jQuery is great