NiallAA Posted June 24, 2013 Share Posted June 24, 2013 First of all, I must admit I know nothing about Javascript. If anyone can point me in the right direction with a correction or working example I would be hugely grateful. I am using the following scripts (one which cycles images in a header, the other which adds a caption to an image). The image cycle one works fine regardless, but the caption one doesn't work while the header is there. Can anyone suggest why they might be fighting? Script 1 (image cycler): $(function() { $('#fixed').capty({ animation: 'fixed' }); }); Script 2 (image captioner): ;(function($) { $.fn.capty = function(settings) { var options = $.extend({}, $.fn.capty.defaults, settings); if (this.length == 0) { debug('Selector invalid or missing!'); return; } else if (this.length > 1) { return this.each(function() { $.fn.capty.apply($(this), [settings]); }); } var $this = $(this), name = $this.attr('name'), $caption = $('<div class="' + options.cCaption + '"/>'), $elem = $this; if ($this.parent().is('a')) { $elem = $this.parent(); } var $image = $elem.wrap('<div class="' + options.cImage + '"/>').parent(), $wrapper = $image.wrap('<div class="' + options.cWrapper + '"/>').parent(); $wrapper.css({ height: $this.height(), overflow: 'hidden', position: 'relative', width: $this.width() }); $caption.css({ height: options.height, opacity: options.opacity, position: 'relative' }) .click(function(evt) { evt.stopPropagation(); }) .appendTo($wrapper); if (name) { var $content = $(name); if ($content.length) { $content.appendTo($caption); } else { $caption.html('<span style="color: #F00;">Content invalid or missing!</span>'); } } else { $caption.html($this.attr('alt')); } if (options.prefix) { $caption.prepend(options.prefix); } if (options.sufix) { $caption.append(options.sufix); } if (options.animation == 'fixed') { $caption.css('top', (-1 * options.height) + 'px'); } else { debug($this.attr('id') + ': invalid animation!'); } return $this; }; function debug(message) { if (window.console && window.console.log) { window.console.log(message); } }; $.fn.capty.defaults = { animation: 'slide', cCaption: 'capty-caption', cImage: 'capty-image', cWrapper: 'capty-wrapper', height: 30, opacity: .7, prefix: '', speed: 200, sufix: '' }; })(jQuery); Quote Link to comment https://forums.phpfreaks.com/topic/279515-jquery-conflicting-scripts/ Share on other sites More sharing options...
Adam Posted June 26, 2013 Share Posted June 26, 2013 You haven't provided the script that cycles through the images, only the definition of jQuery.capty() and a call to it. Quote Link to comment https://forums.phpfreaks.com/topic/279515-jquery-conflicting-scripts/#findComment-1437926 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.