Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Jquery plugin creates unwanted #

11:02 pm on Nov 12, 2012 (gmt 0)

Full Member

5+ Year Member

joined:Apr 26, 2009
posts: 275
votes: 2

Hello guys!

I have a little piece of javascript to support couple of functions such as navigation on my jquery slider. Recently I have noticed that when you click on the navigation button it does what it suppose to do but also creates an extra character in URL "#". I have checked the script and found where and why it is being added, but how to fix it's not added when navigation is clicked, I have no idea. is there any chance that someone can help or at least point me to the right direction. Please see the full code below

<script type="text/javascript">
var fadeTimer;
var slideSpeed = 8000;
jQuery(document).ready(function() {
// add nav buttons
var slideCount = jQuery('#fader ul li').length;

var randomnumber=Math.floor(Math.random()* slideCount);

for ($i = 0; $i < slideCount; $i++) {
jQuery('#faderNav').prepend('<a href="#"><\/a>');

jQuery('#faderNav a').eq(randomnumber).addClass('active');
jQuery('#fader ul li').eq(randomnumber-1).addClass('active');

var next = jQuery('#fader ul .active').next();
if (next.length > 0) {

} else {
var next = jQuery('#fader ul li:first');

jQuery('#fader ul .active').fadeOut().removeClass('active');

// work out nav width
var navBtn = jQuery('#faderNav a');
var navBtnWidth = navBtn.outerWidth(true);
var navWidth = navBtn.length * navBtnWidth;
// set nav width
// add negative margin to center the nav
var negMarg = navWidth / 2;

// start timer

var fadeTimer = setInterval("faderTimer()", slideSpeed);

jQuery('#faderNav a').live('click',function() {
var index = jQuery(this).index('#faderNav a');
jQuery('#faderNav a').removeClass('active');
jQuery('#faderNav a').eq(index).addClass('active');
jQuery('#fader ul .active').fadeOut().removeClass('active');
jQuery('#fader ul li').eq(index).fadeIn('slow').addClass('active');

function faderTimer() {
var next = jQuery('#fader ul .active').next();
if (next.length > 0) {

} else {
var next = jQuery('#fader ul li:first');

var navIndex = next.index('#fader ul li');
jQuery('#faderNav a').removeClass('active');
jQuery('#faderNav a').eq(navIndex).addClass('active');
jQuery('#fader ul .active').fadeOut().removeClass('active');


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members