Originally Posted by shouts
Thank you for your help! Fixed the bracket, used the debugger. Can it show the values for variables?
Are you using Chrome? (Below will be roughly the same in all browsers, but will be correct for Chrome.)
First, set a breakpoint in the code.
-- Click on the Sources tab
-- If the JS code is not shown, look for the little right arrow at the very top left
of the tab space and click on it. That will show you a list of the files being used for this page. Find the one with the JS code you are interested in and clock on it.
-- Find the line where you want to inspect values, etc., and click to the far left of it
-- A blue arrow will appear indicating you have a breakpoint on that line
Second, make sure you hit the breakpoint.
-- Hit a button, make a selection, click a link, etc., etc., Whatever you need to do to get your JS code to reach that breakpoint.
-- If the breakpoint will only be hit during page startup, just hit F5 to refresh the page
Third, look for your variable. Two ways:
(1) In the far right column, look for "Scope variables" and then for the KIND of variable: Local, Closure, Global. Expand the appropriate scope and find your variable. It will be there by name, with its value. (If it's an array, you can expand the array to find the individual elements. If it's an object, you can find the elements of the object.)
(2) [Often the easier choice!] Simply hover your mouse over any usage of the variable in the code visible in the Source tab. The value should pop up in a nice readable overlay.
And all the above is just getting started with the debugger. There's a lot more you can do with it.
Look at "Watch Expressions". Investigate the little plus sign that is part of them.
Look at the little icons above "Watch Expressions". Hover over each one to find out what it is used for.