Jump to content

Combining jQuery and Javascript


iwato

Recommended Posts

General Question: Though aware that jQuery is just an adapted form of Javascript, I am confused about their simultaneous use and interaction. Although it seems very probable that one can employ jQuery wherever one employs Javascript, can one employ Javascript wherever there is jQuery. In my previous example entitled Turning the jQuery Overlay Tool Target Property into an Array I am wondering whether I could just as easily create my envisioned target property array inside the JQuery code as outside. For example, would it make a difference if I wrote,

<script>$(window).load(function() {	var overlay_target = Array('#overlay_1', '#overlay_2', ,,,, '#overlay_N);	$("img[rel]").overlay({		effect:"apple"	});	$("em.EM_Overlay").overlay({		effect:"apple",		target:"overlay_target[]"	});});</script>

or

<script>var overlay_target = Array('#overlay_1', '#overlay_2', ,,,, '#overlay_N);$(window).load(function() {	$("img[rel]").overlay({		 effect:"apple"	});	$("em.EM_Overlay").overlay({		 effect:"apple",		 target:"overlay_target[]"	});});</script>

Roddy :Pleased:

Link to comment
Share on other sites

jQuery is Javascript. It's not a different language, it's a library that someone created using Javascript. You can mix them in any way that keeps the syntax legal. The $ identifier in jQuery is a Javascript function object. Functions are objects in Javascript, so you can call it like a function or access properties and methods like an object. That's not something added by jQuery, that's a feature of Javascript that makes jQuery possible. If you want to assign an array you can do it like this: target:overlay_target or inline: target:['#overlay_1', '#overlay_2', ,,,, '#overlay_N']

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...