Search Results

Search found 668 results on 27 pages for 'addclass'.

Page 4/27 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • jQuery question from a person who can't javascript

    - by Evilalan
    So I'm trying to adapt this Dropdown menu on Joomla the styles work great as expected so I'll post the javascript includes on the head of my website: <script type='text/javascript' src='js/jquery.js'></script> <script type='text/javascript' src='js/dropdown.js'></script> <script type='text/javascript'> $(function() { $('.menu').droppy(); }); </script> <script type='text/javascript'> $(function() { $('.menu').droppy({speed: 100}); }); </script> ok I don't know why its is not working I'll post the dropdown.js should I post the jQuery too? it's really big! $.fn.droppy = function(options) { options = $.extend({speed: 250}, options || {}); this.each(function() { var root = this, zIndex = 1000; function getSubnav(ele) { if (ele.nodeName.toLowerCase() == 'li') { var subnav = $('> ul', ele); return subnav.length ? subnav[0] : null; } else { return ele; } } function getActuator(ele) { if (ele.nodeName.toLowerCase() == 'ul') { return $(ele).parents('li')[0]; } else { return ele; } } function hide() { var subnav = getSubnav(this); if (!subnav) return; $.data(subnav, 'cancelHide', false); setTimeout(function() { if (!$.data(subnav, 'cancelHide')) { $(subnav).slideUp(options.speed); } }, 500); } function show() { var subnav = getSubnav(this); if (!subnav) return; $.data(subnav, 'cancelHide', true); $(subnav).css({zIndex: zIndex++}).slideDown(options.speed); if (this.nodeName.toLowerCase() == 'ul') { var li = getActuator(this); $(li).addClass('hover'); $('> a', li).addClass('hover'); } } $('ul, li', this).hover(show, hide); $('li', this).hover( function() { $(this).addClass('hover'); $('> a', this).addClass('hover'); }, function() { $(this).removeClass('hover'); $('> a', this).removeClass('hover'); } ); }); }; My question here is: Why is it not working! I know that this is really complex (I don't anything about JavaScript) but if you help me I'll post a tutorial and edited files that will help a lot of people! By the way I've download jQuery from the original site so I don't think that this can be the problem! Thanks in advance!

    Read the article

  • How to move an anonymous function out

    - by cf_PhillipSenn
    I have a $.ajax call with an error callback: error: function(result){ $('#msg').text(result.statusText).addClass('err'); } I'd like to change it to a more generic: error: myError(result) And then all by itself: function myError(theError){ $('#msg').text(theError.statusText).addClass('err'); } But firebug is telling me "result" is not defined.

    Read the article

  • Jquery Content Cycle Next/Previous not working

    - by user340745
    I have a definition list with a lot of text inside of it. When a user comes to the page, I want the jQuery to hide two thirds of that content, add a next and previous button where appropriate, and fade the content in and out. The first third of the content is .issue-group-1, the second third is .issue-group-3, the third, .issue-group-3. I am trying to set it so that when the user hits the next button, the next button changes classes, and thus acts differently the next time the user clicks it (that is, it takes them to the third page instead of the second. Right now, the next/previous buttons are working on the first and second "pages" but the next button to the third page won't work. My code is probably too long and this is maybe not the best way to do it--I'm new to jquery. Any suggestions would be helpful. $(document).ready(function(){ $('.issue-group-2, .issue-group-3').hide(); $('a#next-button.page1').fadeIn(500); $('a#next-button.page1').click(function() { $(this).removeClass('page1').addClass('page2'); $('.issue-group-1').fadeOut(500, function() { $('.issue-group-2').fadeIn(500); }); $('a#previous-button').fadeIn(500); }); $('a#previous-button.page2').click(function() { $('#next-button.page2').removeClass('page2').addClass('page1'); $('.issue-group-2').fadeOut(500, function() { $('.issue-group-1').fadeIn(500); }); $('a#previous-button').fadeOut(500); }); $('a#next-button.page2').click(function() { $('a#previous-button').removeClass('page2').addClass('page3'); $('.issue-group-2').fadeOut(500, function() { $('.issue-group-3').fadeIn(500); }); $('a#next-button').fadeOut(500); }); $('a#previous-button.page3').click(function() { $(this).removeClass('page3').addClass('page2'); $('.issue-group-2').fadeOut(500, function() { $('.issue-group-2').fadeIn(500); }); $('a#next-button').fadeIn(500); }); });

    Read the article

  • Why is jQuery's .removeClass() adding a space to the class attribute?

    - by Sosh
    I'm having some strange issues with .removeClass() and .addClass() in jQuery. Specifically it seems that when I use .removeClass() the class is indeed removed, but a single space is left in it's place. then when I .addClass("secondclass") I get class=" secondclass" (with the space in front). I'm using jQuery 1.4.1 Is this intended behaviour or a bug? How to stop it?

    Read the article

  • jquery onclick for expanding text content on the right?

    - by Jon Snow
    Hi I am trying to achieve the same effect as it is on hover on my fiddle, I would like to use jquery click/toggle to expand the content instead of seeing it on hover I am trying the basic addClass with jquery/css but somehow it's breaking off and cannot figure it out how to work properly Would appreciate any help or advice on the following, thanks a lot in advance, here is the fiddle i created with the jquery I am using $(document).ready(function(){ $(".gamewrapper").click(function(){ $(".gamewrapper").addClass("expand"); }); }); Thanks

    Read the article

  • jQuery UI Tabs Plugin Broke

    - by Warren J Thompson
    We are using the jquery ui tabs arrow plugin from this fiddle: http://jsfiddle.net/dECtZ/282/, but like many plugins, it breaks with the latest version of jQuery. We were able to get the csscur to work, but still get the following error in the jquery core (line 353): Uncaught TypeError: Cannot assign to read only property 'length' of function (e,t){if(!this._createWidget)return new o(e,t);arguments.length&&this._createWidget(e,t)} Code is as follows: (function($, undefined) { if (!$.xui) { $.xui = {}; } var tabs = $.extend({}, $.ui.tabs.prototype), _super = { _create: tabs._create, _destroy: tabs._destroy, _update: tabs._update }; $.xui.tabs = $.extend(tabs, { options: $.extend({}, tabs.options, { scrollable: false, changeOnScroll: false, closable: false, resizable: false, resizeHandles: "e,s,se" }), _create: function() { var self = this, o = self.options; _super._create.apply(self); if (o.scrollable) { self.element.addClass("ui-tabs-scrollable"); var scrollContainer = $('<div class="ui-tabs-scroll-container"></div>').prependTo(this.element); self.header = $('<div class="ui-tabs-nav-scrollable ui-widget-header ui-corner-all"></div>').prependTo(scrollContainer); var nav = self.element.find(".ui-tabs-nav:first").removeClass("ui-widget-header ui-corner-all").appendTo(this.header); var arrowsNav = $('<ol class="ui-helper-reset ui-helper-clearfix ui-tabs-nav-arrows"></ol>').prependTo(self.element); var navPrev = $('<li class="ui-tabs-arrow-previous ui-state-default ui-corner-bl ui-corner-tl" title="Previous"><a href="#"><span class="ui-icon ui-icon-carat-1-w">Previous tab</span></a></li>').prependTo(arrowsNav).hide(), navNext = $('<li class="ui-tabs-arrow-next ui-state-default ui-corner-tr ui-corner-br" title="Next"><a href="#"><span class="ui-icon ui-icon-carat-1-e">Next tab</span></a></li>').appendTo(arrowsNav).hide(); var scrollTo = function(to, delay) { var navWidth = 0, arrowWidth = navPrev.outerWidth(), marginLeft = -(parseInt(nav.css("marginLeft"), 10)), hwidth = self.header.width(), newMargin = 0; nav.find("li").each(function() { navWidth += $(this).outerWidth(true); }); if (to instanceof $.Event) { } else { newMargin = marginLeft+to; if (newMargin > (navWidth-hwidth)) { newMargin = (navWidth-hwidth); } else if (newMargin < 0) { newMargin = 0; } nav.stop(true).animate({ marginLeft: -(newMargin) }, delay, function(){ $(window).trigger("resize.tabs"); }); } } var holdTimer = false; navPrev.add(navNext).bind({ "click": function(e) { var isNext = this === navNext[0]; e.preventDefault(); if (o.changeOnScroll) { self.select(self.options.selected + (isNext ? 1 : -1)); } else { if (!holdTimer) scrollTo(isNext ? 150 : -150, 250); } }, "mousedown": function(e){ if (!o.changeOnScroll) { var isNext = this === navNext[0], duration = 10, pos = 15, timer; if (holdTimer) clearTimeout(holdTimer); holdTimer = setTimeout(timer = function(){ scrollTo(isNext ? pos : -(pos), duration); holdTimer = setTimeout(arguments.callee, duration); }, 150); } }, "mouseup mouseout": function(e){ if (!o.changeOnScroll) { clearTimeout(holdTimer); holdTimer = false; nav.stop(); } } }); self.header.bind('mousewheel', function(e, d, dX, dY) { e.preventDefault(); if (d === -1) { navNext.click(); } else if (d === 1) { navPrev.click(); } }); $(window).bind("resize.tabs", function(e) { var navWidth = 0; var arrowWidth = navPrev.outerWidth(); nav.find("li").each(function() { navWidth += $(this).outerWidth(true); }); var marginLeft = -(parseInt(nav.css("marginLeft"), 10)), hwidth = self.header.width(); if (navWidth > (hwidth+marginLeft)) { self.header.addClass("ui-tabs-arrow-r"); navNext.show("fade"); if (marginLeft > 0) { self.header.addClass("ui-tabs-arrow-l"); navPrev.show("fade"); } else { self.header.removeClass("ui-tabs-arrow-l"); navPrev.hide("fade"); } } else { self.header.removeClass("ui-tabs-arrows ui-tabs-arrow-l"); navNext.hide("fade"); if (marginLeft > 0) { self.header.addClass("ui-tabs-arrow-l"); navPrev.show("fade"); } else { self.header.removeClass("ui-tabs-arrow-l"); navPrev.hide("fade"); } } }).trigger("resize.tabs"); arrowsNav.find("li").bind({ "mouseenter focus": function(e) { $(this).addClass("ui-state-hover"); }, "mouseleave blur": function(e) { $(this).removeClass("ui-state-hover"); } }); this.anchors.bind("click.tabs", function(){ var li = $(this).parent(), arrowWidth = navPrev.outerWidth(), width = li.outerWidth(true), hwidth = self.header.width(), pos = li.position().left, marginLeft = -(parseInt(nav.stop(true,true).css("marginLeft"),10)), newMargin = -1; if (li.index() === 0) { newMargin = 0; } else if ((pos+width) >= (hwidth+marginLeft)) { newMargin = pos-hwidth+width; if ((li.index()+1) < nav.find("li").length) { newMargin += arrowWidth; } } else if (pos < marginLeft) { newMargin = pos-arrowWidth; } if (newMargin > -1) { nav.animate({ marginLeft: -(newMargin) }, 250, function(){ $(window).trigger("resize.tabs"); }); } }); } return self; }, _update: function(){ console.log(arguments); _super._update.apply(this); } }); $.widget("xui.tabs", $.xui.tabs); })(jQuery); $(function() { $("#tabs").tabs({ scrollable: true, changeOnScroll: false, closable: true }); $("#switcher").themeswitcher(); });

    Read the article

  • jQuery Validation Plugin: Validating Checkboxes with Different Names

    - by Michael
    I have a set of 4 checkboxes, all with different names, and require that at least 1 is checked. I know there are a few posts on here already trying to answer this question. The solution that seems to be most logical to me is the answer posted on Question 1734840, but I can't seem to get it working! What's wrong with my code? Or any other new coding ideas to get this working? I have set the class on all of them to 'require-one'. My jQuery code is $(document).ready(function(){ $("#itemForm").validate({ highlight: function(element, errorClass, validClass) { $(element).addClass(errorClass).removeClass(validClass); $(element.form).find("label[for=" + element.name + "]") .addClass("radioerror"); }, unhighlight: function(element, errorClass, validClass) { $(element).removeClass(errorClass).addClass(validClass); $(element.form).find("label[for=" + element.name + "]") .removeClass("radioerror"); }, rules: { 'require-one': { required : { depends: function(element) { var allBoxes = $('.require-one'); if (allBoxes.filter(':checked').length == 0) { if (allBoxes.eq(element).length != 0) { return true; } } return false; } } } , }, errorPlacement: function(error, element) { if ( element.is("#other_descrip") ) error.appendTo("#othererror" ); if ( element.is("#itemlist") ) error.appendTo("#itemerror" ); } }); });

    Read the article

  • jqGrid zebra striping problem

    - by ShiVik
    Hello all I have just started with jQuery. I am trying to implement zebra striping in my jqGrid class. I am having the problem when user clicks on sort column, all rows get rearranged and the zebra striping is blown away. Zebra Striping code $("#item_table tbody tr:odd").addClass("alt"); $("#item_table tbody tr").mouseover(function() { $(this).addClass("over"); }); $("#item_table tbody tr").mouseout(function() { $(this).removeClass("over"); }); jqGrid code jQuery.extend(jQuery.jgrid.defaults, { autowidth: true, hidegrid: false, colModel:[ { name: 'icon', index: 'icon', width: 0, resizable: false }, { name: 'name', index: 'name', width: 0, resizable: false }, { name: 'price', index: 'price', width: 0, sorttype: "int", resizable: false } ], onSortCol: function(index, iCol, sortorder) { // This doesn't work - IT SHOULDN'T EITHER, since event is called // just after clicking to sort but before actual sorting jQuery("#item_table tbody tr:odd").addClass("odd"); }, caption: "Item Table" }); I also tried loadComplete, gridComplete events, but to no avail. How should I proceed with this? Have I even started this right? Regards Vikram

    Read the article

  • a selector which has this selector together with a class selector

    - by Woho87
    Here is an analogy of my problem(a selector which has this selector together with a class selector): Let say that I selects all yellow(classes) div elements in a arbitrary HTML document. And I want each to check if the attribute is yes = 1. If the attribute 'yes' equals '1', then I want the child with class 'blue' have the attribute 'no' equals '1'; $('div .yellow').each(function(){ if($(this).attr('yes') == 1){ $(this '.blue:first-child').attr('no', 1);//This line needs to be fixed } }); I know that the line this.getElementsByClassName('blue')[0] fixes this problem. But in my real problem (not this analogy) I want to use addClass and removeClass which only functions with jQuery objects. It is to cumbersome to use other functions than addClass and removeClass. UPDATE: Here is a code snippet from my real problem. I got some problem with "this" in javascript. I want a invited button to have the className visible when I click on it. The button lies within a div element with className 'box'. I know that there are problem with 'this' on the code snippet. But I want the button and not the box to change to visible $('.Box').each(function(){ if($(this).attr('hasButton') != 1){ var invite = document.createElement('div'); invite.className = 'invite invisible'; invite.innerHTML = 'invite'; $(this).attr('hasButton', 1); this.appendChild(invite); invite.addEventListener('mouseover', function(event){ $('.invite', this).removeClass('invisible');//this line is not functioning $('.invite', this).addClass('visible');//neither this }, false); } });

    Read the article

  • CSS 3 - Scaling CSS Transitions

    - by Viv Shc
    I am trying to scale an image when you mouseenter, which is working. I would like the image to gradually scale up with an ease transition. I used ease-in-out, which it's not working. Any suggestions? Also, I used addClass & removeClass twice in the jquery code. Is there a way to only use it once? Thanks! <style> .image { opacity: 0.5; } .image.opaque { opacity: 1; } .size{ transform:scale(1.2); -ms-transform:scale(1.2); /* IE 9 */ -webkit-transform:scale(1.2); /* Safari and Chrome */ -webkit-transition: scale 2s ease-in-out; -moz-transition: scale 2s ease-in-out; -o-transition: scale 2s ease-in-out; -ms-transition: scale 2s ease-in-out; transition: scale 2s ease-in-out; transition: opacity 2s; } </style> <script> $(document).ready(function() { $(".image").mouseenter(function() { $(this).addClass("opaque"); $(this).addClass("size"); }); $(".image").mouseleave(function() { $(this).removeClass("opaque"); $(this).removeClass("size"); }); }); <div id="gallery"> <h3>Gallery of images</h3> <img class="image" src="images/gnu.jpg" height="200px" width="250px"> <img class="image" src="images/tiger.jpg" height="200px" width="250px"> <img class="image" src="images/black_rhino.jpg" height="200px" width="250px"> <img class="image" src="images/cape_buffalo.jpg" height="200px" width="250px"> </div>

    Read the article

  • jQuery : add css class to menu item based on browser scroller position

    - by antosha
    Hi, I have a menu: <ul class="menu-bottom"> <li id="m1" class="active"><a id="1" href="#"><span>Link 1</span></a></li> <li id="m2"><a id="2" href="#"><span>Link 2</span></a></li> <li id="m3"><a id="3" href="#"><span>Link 3</span></a></li> </ul> I want that depending of browser's scroller position, the "active" class goes the correct < li element. This is how I see it : if ($(document).height() == 500) { $('#m1').parent().addClass('active'). siblings().removeClass('active'); } if ($(document).height() == 1000) { $('#m2').parent().addClass('active'). siblings().removeClass('active'); } if ($(document).height() == 1500) { $('#m2').parent().addClass('active'). siblings().removeClass('active'); } I am not very familiar with jQuery Dimensions properties so this code doesn't make much sense, but I hope you get the idea. If someone could tell me how to make this work, it would be really cool. Thanks :)

    Read the article

  • Custom Jquery slideshow doesn't want to reset?

    - by Jared
    Hello, Under $(document).ready(function(), I have the following code: num = $("#mainContentCategoryLinksWrapper > div").size(); This makes num equal the length of the children of #mainContentCategoryLinksWrapper. Currently, this equals 4. Above the $(document).ready(function( I have this: var timesRun = 0; function slideshow(){ if(timesRun < num){ $(".arrowIn").stop().animate({color: "#a12324", textIndent: "30px", backgroundPosition: '0px 0px'}, 100, function(){ //the first child in the series has a class of "arrowIn" $(".arrowIn").next().addClass("replaceMe"); //Adds the ".replaceMe" placeholder the the next element. $(".arrowIn").removeClass("arrowIn"); //Deletes the class on the current element $(".replaceMe").addClass("arrowIn").removeClass("replaceMe"); //reassigns ".arrowIn" over ".replaceMe" timesRun = timesRun + 1; //increases number of times run }).prev().animate({color: "#000000", textIndent: "25px", backgroundPosition: '0px -25px'}, {duration: 50}); //puts the previous element back to it's original position }else{ timesRun = 0; $(".arrowIn").removeClass("arrowIn"); $("#mainContentCategoryLinksWrapper:first-child").addClass("arrowIn"); //this is supposed to reset timesRun, and set the first child in the series back to the original ".arrowIn" } } setInterval( 'slideshow()', 1000 ); So here is the what the code does: 1) Animates the first in the series of 4 (#1) timesRun = 1 2) Animates the second in the series of 4 (#2) timesRun = 2 3) Animates the third in the series of 4 (#3) timesRun = 3 4) Animates the fourth in the series of 4 (#4) timesRun = 4 5) timesRun is now longer less than num. Reset class names back to original to .arrowIn, set timesRun to 0. However, when the slideshow() is reexectuted, it doesn't start over. Any ideas? See www.raceramps.com/v3 for an example.

    Read the article

  • What's wrong with this jQuery fading gallery code?

    - by Meep3D
    So I am creating a fading gallery and am a bit of a noob to javascript (but not to programming). I have no idea what is wrong though. Here's the function in question: /* */ function show_next () { // Hide current $('.s_gallery_images li.s_current').fadeTo(200, .2); $('.s_gallery_images li.s_current').css("border","1px green solid"); // if ($('.s_gallery_images li').hasClass ('.s_current')) { console.log ('Incrementing existing'); // Class already exists $('.s_current:first').removeClass('s_current').next().addClass('s_current'); // Was that the last one? if ($('.s_gallery_images li').hasClass ('.s_current')) { console.log ('Current found'); } else { // Class doesn't exist - add to first $('.s_gallery_images li:first').addClass ('.s_current'); console.log ('Wrapping'); } } else { console.log ('Adding new class'); // Class doesn't exist - add to first $('.s_gallery_images li:first').addClass ('.s_current'); } // Show new marked item $('.s_gallery_images li.s_current').fadeTo(200, .8); } The HTML is a very simple: <ul class="s_gallery_images"> <li><img src="imagename" alt="alt" /></li> <li><img src="imagename" alt="alt" /></li> <li><img src="imagename" alt="alt" /></li> </ul> And it displays the list and the images fine. I am using firebugs console.log for debugging, plus have a class set for s_current (bright border) but nothing happens at all. The firebug console log says: Adding New Class Incrementing Existing Current Found Incrementing Existing Current Found Incrementing Existing Current Found Incrementing Existing Current Found ... to infinity The function is called on a setInterval timer, and as far as I can tell it should be working (and I have done something similar before), but it just isn't happening :(

    Read the article

  • jQuery Validation: Validating Checkboxes with Different Names

    - by Michael
    I have a set of 4 checkboxes, all with different names, and require that at least 1 is checked. I know there are a few posts on here already trying to answer this question. The solution that seems to be most logical to me is the answer posted on Question 1734840, but I can't seem to get it working! What's wrong with my code? Or any other new coding ideas to get this working? I have set the class on all of them to 'require-one'. My jQuery code is $(document).ready(function(){ $("#itemForm").validate({ highlight: function(element, errorClass, validClass) { $(element).addClass(errorClass).removeClass(validClass); $(element.form).find("label[for=" + element.name + "]") .addClass("radioerror"); }, unhighlight: function(element, errorClass, validClass) { $(element).removeClass(errorClass).addClass(validClass); $(element.form).find("label[for=" + element.name + "]") .removeClass("radioerror"); }, rules: { 'require-one': { required : { depends: function(element) { var allBoxes = $('.require-one'); if (allBoxes.filter(':checked').length == 0) { if (allBoxes.eq(element).length != 0) { return true; } } return false; } } } , }, errorPlacement: function(error, element) { if ( element.is("#other_descrip") ) error.appendTo("#othererror" ); if ( element.is("#itemlist") ) error.appendTo("#itemerror" ); } }); });

    Read the article

  • jQuery - how to repeat a function within itself to include nested files

    - by brandonjp
    I'm not sure what to call this question, since it involves a variety of things, but we'll start with the first issue... I've been trying to write a simple to use jQuery for includes (similar to php or ssi) on static html sites. Whenever it finds div.jqinclude it gets attr('title') (which is my external html file), then uses load() to include the external html file. Afterwards it changes the class of the div to jqincluded So my main index.html might contain several lines like so: <div class="jqinclude" title="menu.html"></div> However, within menu.html there might be other includes nested. So it needs to make the first level of includes, then perform the same action on the newly included content. So far it works fine, but it's very verbose and only goes a couple levels deep. How would I make the following repeated function to continually loop until no more class="jqinclude" elements are left on the page? I've tried arguments.callee and some other convoluted wacky attempts to no avail. I'm also interested to know if there's another completely different way I should be doing this. $('div.jqinclude').each(function() { // begin repeat here var file = $(this).attr('title'); $(this).load(file, function() { $(this).removeClass('jqinclude').addClass('jqincluded'); $(this).find('div.jqinclude').each(function() { // end repeat here var file = $(this).attr('title'); $(this).load(file, function() { $(this).removeClass('jqinclude').addClass('jqincluded'); $(this).find('div.jqinclude').each(function() { var file = $(this).attr('title'); $(this).load(file, function() { $(this).removeClass('jqinclude').addClass('jqincluded'); }); }); }); }); }); });

    Read the article

  • Swapping content in a seperate div on hover

    - by Fuego DeBassi
    I feel like this should work: $(".module .one").hover(function() { $("#viewport #one").addClass('red'); }); Basically I am hiding all the .children of "#viewport on load, then when a seperate element is hovered, in this case .module .one I want to change something on the corresponding viewport ID #viewport #one. Basic idea is a variable content window, where when a thumbnail or whatever I put in the modules swaps the content shown in the viewport. Something I am doing wrong? Here is my full code: <script type="text/javascript"> $(document).ready(function() { $(".module .caption").hide(); $("#viewport").children().hide(); $(".module").hover(function() { $(this).find(".caption").slideDown().end().siblings('.module').addClass('under'); },function() { $(this).find(".caption").slideUp().end().siblings('.module').removeClass('under'); }); $(".module .one").hover(function() { $("#viewport #one").addClass('red'); }); }); </script> The bigger hover function in the middle is for some fancy rollover effects that the modules will perform themselves, but for these purposes I just want to figure out why I can't add a Class to a separate element when another is hovered. Would love some help/advice!

    Read the article

  • jQuery sliding animation not working

    - by Jake Zeitz
    I have three divs stacked on each other but offset so that a part of each div is visible. When one of the bottom divs is clicked I want the top div to animate out and back into the stack at the bottom, then the div that is clicked will appear at the top. So far I only have the code for when the middle div is clicked, but I cannot get it to work properly. What am I doing wrong? (I also realize that the code I wrote is probably terrible, this is the first jQuery code I have written.) The css is very very simple: .first { z-index: 3; } .second { z-index: 2; } .third { z-index: 1; } The basic html is this: <div class="first"></div> <div class="second"></div> <div class="third"></div> Here is my code: $("div.second").click(function () { $("div.first").animate({ left: "-=200px"}, {duration: "fast", complete: function () { $("div.first").removeClass("first").addClass("third").animate({left: "+=350px", top: "+=60px"}, "fast"); } }); $("div.second").animate({ left: "-=24px", top: "-=30px"}, {duration: "fast", complete: function () { $("div.second").removeClass("second").addClass("first"); } }); $("div.third").animate({ left: "-=24px", top: "-=30px"}, {duration: "fast", complete: function () { $("div.third").removeClass("third").addClass("second"); } }); }); I can get the div.first to move to the side and back. But now I can't get the classes to stay changed. What keeps happening is the div.second will remove it's class and add .first in the animation, but when the animation is complete, it acts like it still has a class of .second.

    Read the article

  • Fading out everything but (this) - while honoring a click()

    - by Kasper Lewau
    I'm trying to achieve a fading navigation system, where everything in the nav but the element being hovered will fade out to say, 0.3 opacity. At the same time, I want clicks to have a greater "value", so as to not fade out a clicked element (or in this case, the active subpage).. That didn't make much sense to me either, I'll just post the code I have. <nav id="main"> <ul> <li> <a>work</a> </li> <li> <a>about me</a> </li> <li> <a>contact</a> </li> </ul> </nav> And the script that makes it sparkle: var nava = "nav#main ul li a"; $(nava).hover(function(){ $(nava).not(this).removeClass().addClass("inactive"); $(this).addClass("active"); }); $(nava).click(function(){ $(this).removeClass().addClass("active"); }); }); And the classes / css(less): .inactive{color:@color2; border-bottom:0 solid #000;} .active{color:@color1; border-bottom:1px solid #000;} nav#main ul li a{color:@color1;} Basically the hover states take priority over the click, which I do not want to happen. Ideally I'd like for all of the anchor elements to revert to its original state whenever you hover out from the unordered list holding it all. If anyone has some pointers on this it'd be greatly appreciated. Cheers!

    Read the article

  • Jquery Returning values to original

    - by Cam
    So my script works perfectly, but here is the issue, I have buttons (Sprite action here) that are 40px height, but the top 20 only shows perfectly. When you click the button ie img the bottom 20px show perfecto! but... Issue, i included in my script a way to return all others to there default (only one should be selected) now, how can I fix this issue that I seem unable to correct as I can select multiple of them ** USERS can switch ** The last part of the script that is the issue. Thanks $(document).ready(function() { $('.form_sub').hide(); $('.theader').addClass('active'); $('.theader_t').click(function() { $('.form_header').show(); $('.form_sub').hide(); $('.theader').addClass('active'); $('.sub_theader').removeClass('active'); }); $('.sub_theader_t').click(function() { $('.form_header').hide(); $('.form_sub').show(); $('.theader').removeClass('active'); $('.sub_theader').addClass('active'); }); $('.top_head_img').click(function() { $(this).css({ position: 'relative', bottom: '20px' }).siblings().css( 'bottom', '0' ); }); }); <ul class="top_head"> <li> <a href="javascript:void(0)" onClick="selectPic5('top');"><img src="custom/images/top2.jpg" alt="Left" border="0" class="top_head_img"/></a> </li> <li> <a href="javascript:void(0)" onClick="selectPic5('center');"><img src="custom/images/mid2.jpg" alt="Center" border="0" class="top_head_img"/></a> </li> <li> <a href="javascript:void(0)" onClick="selectPic5('bottom');"><img src="custom/images/bot2.jpg" alt="Right" border="0" class="top_head_img"/></a> </li> </ul>

    Read the article

  • How to disable form submit if the username is not available

    - by Rajasekar
    I have checked the user name availability. The problem is, even if the username is not available, the form is posting. Edited Code: <SCRIPT type="text/javascript"> $(document).ready(function(){ $("#emailch").change(function() { var usr = $("#emailch").val(); if(usr.length >= 3) { $("#status").html('<img src="images/loader.gif" align="absmiddle">&nbsp;Checking availability...'); $.ajax({ type: "POST", url: "includes/check.php", data: "username="+ usr, success: function(msg){ $("#status").ajaxComplete(function(event, request, settings){ if(msg == 'OK') { $("#username").removeClass('object_error'); // if necessary $("#username").addClass("object_ok"); $(this).html('&nbsp;<img src="images/tick.gif" align="absmiddle">'); } else { $("#username").removeClass('object_ok'); // if necessary $("#username").addClass("object_error"); $(this).html(msg); } }); } }); } else { $("#status").html('<font color="red">The username should have at least <strong>3</strong> characters.</font>'); $("#username").removeClass('object_ok'); // if necessary $("#username").addClass("object_error"); } }); }); </SCRIPT> What I want is that, the form should not be posted if the user name is not available. I have tried by using return false; in IF CONDITION but it fails. Please suggest any alternate method. Any help will be appreciated.

    Read the article

  • Returning two or more values from a function

    - by cf_PhillipSenn
    I need to return multiple values from a ColdFusion function in an ajax callback function. Here's what I've got: $('input[name="StateName"]').live('change', function() { var StateID = $(this).parents('tr').attr('id'); var StateName = $(this).val(); $.ajax({ url: 'Remote/State.cfc' ,type: "POST" ,data: { 'method': 'UpdateStateName' ,'StateID': StateID ,'StateName': StateName } ,success: function(result){ if (isNaN(result)) { $('#msg').text(result).addClass('err'); } else { $('#' + result + ' input[name="StateName"]').addClass('changed'); }; } ,error: function(msg){ $('#msg').text('Connection error').addClass('err'); } }); }); If I trap a database error, then the success callback is fired, and the result is Not a Number (It is in fact, the text of the error message). I need the function to also pass back other values. One might be the primary key of the row that caused the error. Another might be the old StateName, so that I can refresh the old value on the screen so that the client will know absolutely for sure that their change did not take effect. I guess I'm breaking the rule of atomicity here and need to fix that, because I'm using result as both the primary key of the row that was updated, or it's the error message if the update fails. I need to return both the primary key and the error message.

    Read the article

  • Unobstrusive pseudo-classes and attribute selectors emulation in IE

    - by Álvaro G. Vicario
    I'm trying to emulate some pseudo-classes and attribute selectors in Internet Explorer 6 and 7, such as :focus, :hover or [type=text]. So far, I've managed to add a class name to the affected elements: $("input, textarea, select") .hover(function(){ $(this).addClass("hover"); }, function(){ $(this).removeClass("hover"); }) .focus(function(){ $(this).addClass("focus"); }) .blur(function(){ $(this).removeClass("focus"); }); $("input[type=text]").each(function(){ $(this).addClass("text"); }); However, I'm still forced to duplicate selector in my style sheets: textarea:focus, textarea.focus{ } And, to make things worse, IE6 seems to ignore all the selectors when it finds an attribute: input[type=text], input.text{ /* IE6 ignores this */ } And, of course, IE6 ignores selectors with multiple classes: input.text.focus{ /* IE6 ignores this */ } So I'm likely to end up with this mess: input[type=text]{ /* Rules here */ } input.text{ /* Same rules again */ } input[type=text]:focus{ } input.text_and_focus{ } input.text_and_hover{ } input.text_and_focus_and_hover{ } My question: is there any way to read the rules or computed style defined for a CSS selector and apply it to certain elements, so I only need to maintain one set of standard CSS?

    Read the article

  • Surely eAsy but I am not able ... JQUERY UI - WIDGET - HEADER

    - by alex
    I was making this simple trial, but can anyone tell me why the distance from the border of DIV to the H2 header is so much ? How can I reduce it ? I don't want space ... Prova WIDGET <link rel="stylesheet" href="jquery-ui-1.8.custom/css/smoothness/jquery-ui-1.8.custom.css" type="text/css"> <link rel="stylesheet" href="jquery-ui-1.8.custom/development-bundle/ui/jquery-ui-1.8.custom.css" type="text/css"> <script src="jquery-ui-1.8.custom/development-bundle/jquery-1.4.2.js" type="text/javascript"></script> <script src="jquery-ui-1.8.custom/js/jquery-ui-1.8.custom.min.js" type="text/javascript"></script> <script type="text/javascript"> $(themify); function themify(){ $("div").addClass("ui-widget ui-widget-content ui-corner-all"); $("input").addClass("ui-button ui-button-text"); $(":header").addClass("ui-widget-header ui-corner-all"); //ui-widget } </script> <style>#test{display:none}</style> <script type="text/javascript"> function rendiVisibile(){ if(document.getElementById("test").style.display = "none"){ $("#test").css({"width":"200px","float":"right","text-align":"center"}); $("#test").show("slide",{},1000); } } </script> </head> <body> <h2>Tentativo widget con DIV</h2> <form action=""> <input type="button" value="Submit" id="pulsante" onclick="rendiVisibile()";><br/></br> <div id="test"> <h2>CIAO</h2> Un saluto </div> </form> </body>

    Read the article

  • Help with simple javascript loop

    - by Gabriel
    Hello, I have a simple javascript that I'd like to loop for multiple elements. Here's my code: <script type='text/javascript'> for(i = 1; i < 100; i++) { $('#link'+i).click(function() { $('#container').removeClass(); $('#container').addClass('templateid'+i); }); } </script> What I'd like to achieve is the same addClass function for multiple id's (e.g. link2, link3, link4), with the corresponding class (e.g. template2, template3, template4). Any help would be hugely appreciated! For reference, an individual call like this one, does work, so I don't see why the loop above doesn't function the same: <script type='text/javascript'> $('#link2').click(function() { $('#container').removeClass(); $('#container').addClass('templateid2'); }); </script>

    Read the article

  • How can I set/store cookie when anchor clicked

    - by Unaverage Guy
    I am trying to use Cookie so that a default style OR a specific style is applied in reference to the anchor tag clicked, even when the browser is closed/reopen. So if the user clicked the second link, close or refresh the browser and reopen, than the style should still be active, if it is their first time the default should apply. This is a little over my turf. Here is the HTML: <a id="default" href="#/">Default Style</a> <a id="style2" href="#/">Style 2</a> <a id="style3" href="#/">Style 3</a> <ol> <li><span>Hello World</span></li> </ol> JQuery: (Compliments of StackOverflow) <script type="text/javascript"> $('#default').on('click',function(){ $('ol li span').removeClass(function() { return $(this).attr('class'); }).addClass('default'); }); $('#style2').click(function(){ $('ol li span').removeClass(function() { return $(this).attr('class'); }).addClass('style2'); }); $('#style3').click(function(){ $('ol li span').removeClass(function() { return $(this).attr('class'); }).addClass('style3'); }); </script> CSS: <style type="text/css"> .default{ color: #333; } .style2{ color: #999; } .style3{ color: #800; } </style>

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >