I’ve for this fiddle ( http://jsfiddle.net/hgGfw/ ) , I’ve been following a slider tutorial and that’s the code I’ve got. It’s using a self invoking function ( I think that’s what it’s called??). Anyway, It works with the jQuery set to “onLoad” on the fiddle, but when it’s on my server it does nothing until it’s wrapped in $(document).ready(…. script. Why is that? JSLint also moans about this;
( direction === 'next' ) ? ++current : --current;
Any idea why? My PHP isn’t bad, so I know the syntax for that statement and it looks fine to me.
Thanks, Dan.
If you place javascript / jquery into the
JavaScriptpanel of a http://jsfiddle.net, it will automatically place your code into a$(window).load(function(){ }block (when the Framework dropdown is set toonLoadand ajQueryoption).If you have a look at the frame source of the result pane, you should see this is the case.
With regards to why JSLint doesn’t like the command, I guess it is expecting an assignment (despite the fact that you are doing incrementation/decrementation on the
currentvariable).If you assign the value to a variable, JSLint is happy. I.e…