1
src="http://code.jquery.com/jquery-latest.min.js" charset="utf-8">

function switch01(){
    $("#con01,#con02,#con03").hide();  
    $("#con04").slideToggle("slow");
};

As I understand, the above code is jQuery code, and it needs the first - reference line to work at all.
For example, CSS code will not work without a reference to a css file (if not inline placed).
But I removed the first line (accidentally), and what I see - the code still works.
Does maybe browser has jQuery inside itself ?
If so - why one can need the above line at all ?
And if so - what about priority issue (in case version's conflict between the referencing and browser's library ?
And, if not so - where is the library placed ?
Maybe - in the eternal, ever-present Universe :).
Or maybe - something is wrong in my understanding (probably).

Alegro
  • 271

4 Answers4

3

Most likely it would be your browser caching it, actually. Try a force-refresh with SHIFT+F5 a few times.

However, looking at that as it stands - it is invalid script and I am surprised it ever worked.

(unless you're pulling it out of context..?)

On most browsers today pressing CTRL+SHIFT+DEL will pop the "Clear Cache Dialog", where you can specify what you want cleared.

nerdwaller
  • 17,384
  • I have Firefoks 17 and clear the cache with F5. The code still works – Alegro Nov 30 '12 at 15:50
  • Just F5 doesn't clear the cache. It would be worth doing the full cache clear, or just trying another browser you've not visited the page on. – nerdwaller Nov 30 '12 at 15:51
  • Now I cleared the cache following this instructions: http://support.mozilla.org/en-US/kb/how-clear-firefox-cache. The code still works. – Alegro Nov 30 '12 at 16:00
  • The assets are definitely coming in somehow. Very odd. – nerdwaller Nov 30 '12 at 16:05
  • What about WAMP server. My page is .php. Should I clear something in WAMP - and how? – Alegro Nov 30 '12 at 16:13
  • I think that part is irrelevant to loading the resources, it is just the backend framework to allow it to run... Very very odd though. – nerdwaller Nov 30 '12 at 16:14
  • Ok, Thanks to EveryOne. I will try with another browser. Or maybe should clear my room from ghosts :). – Alegro Nov 30 '12 at 16:25
2

The code you posted will not work without jQuery or simliar JS framework. If it works without the first line where you're including the jQuery library, then it may also be loaded by something else. Browsers do not include the jQuery library by default.

You can look in the Chrome inspector or Firefox's Firebug to view the resources that are being loaded; see if you can find jQuery in that list.

2

Caching, probably. Clear the browser's cache and see what happens. The instructions for clearing the cache depend on the browser in question.

Ian Atkin
  • 1,094
0

I have faced same problem once. This was happened because of your browser's caching. Try to clear your browser cache or run your code in different browser where you never run before. or you can try to refresh page many times.

Hope this will help you. Thank you.

HarshShah
  • 119
  • 7