Jump to content

2 Javascripts conflict


dsp77

Recommended Posts

Hello,

I have 2 java scripts that don't work together i tried to combine them but no success the first script is for the menu:

<script type = "text/javascript" >

var $jq = jQuery.noConflict();
$jq(document).ready(function() {

	// default behavior
	$jq(".blink").cyclicFade();
	$jq("#blink2").cyclicFade({
		repeat: 0,
		params: [
			{fadeout:100, stayout:300, opout:0, fadein:100, stayin:3000, opin:0.5},
			{fadeout:100, stayout:300, opout:0, fadein:100, stayin:300, opin:0.75},
			{fadeout:100, stayout:300, opout:0, fadein:100, stayin:300, opin:1.0}
		]
	});
	$jq("#blink3").cyclicFade({
		repeat: 4,
		params: [
			{fadeout:2000, stayout:300, opout:0, fadein:2000, stayin:300, opin:1.0}
		]
	});		
});	
</script>

and the second is for a image slider:

<script type="text/javascript">
$(window).load(function(){	

var options = {
			delay: 3000,
			type:['fade','columnflyin','rowgrowin','blockshrink','columndropin','rowslideleft','blockgrow','columnfade','blockrandomin','rowthin','blockdrop','columnrandom','rowrandom','blockflyout','columnthin','blockdropin'],
			controls:'.controls.first_example',
			next:'.next',
			prev:'.prev'
		};
$('.container.first_example').svUltimateSlider(options);


});
</script>

Any advise to make them work together?

Link to comment
https://forums.phpfreaks.com/topic/229229-2-javascripts-conflict/
Share on other sites

var $jq = jQuery.noConflict();

 

You're removing the $ alias to jQuery with this line, but then trying to use the $ alias later with the second script. Unless you're using other frameworks, you don't need to do that. Remove the line quoted above and convert all "$jq" to just "$". If you do have other frameworks, or use $ in some other way, go through the second script and convert all "$" to "$jq".

 

One other option, if you don't like the "$jq" alias, is to remove the assignment in the line above (i.e. "var $jq =") and access jQuery through it's normal var name "jQuery" - instead of "$jq".

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.