Search Results

Search found 90 results on 4 pages for 'toggleclass'.

Page 1/4 | 1 2 3 4  | Next Page >

  • toggleClass messing something up.

    - by Mathias Nielsen
    Hi I am using playing around with the Pretty-checkboxes-plugin and have a problem. The plugin can be seen here http://aaronweyenberg.com/90/pretty-checkboxes-with-jquery As you can see, this uses two links to select and deselect. I want it to only use one link and then change the class to make it work the other way the next time it is clicked. It should be simple enough. I have been trying to get it working with toggleClass. I simply put in the toggleClass statement so the code looks like so: $(document).ready(function() { /* see if anything is previously checked and reflect that in the view*/ $(".checklist input:checked").parent().addClass("selected"); /* handle the user selections */ $(".checklist .checkbox-select").click( function(event) { event.preventDefault(); $(this).parent().addClass("selected"); $(this).parent().find(":checkbox").attr("checked","checked"); $(this).toggleClass("checkbox-select checkbox-deselect"); } ); $(".checklist .checkbox-deselect").click( function(event) { event.preventDefault(); $(this).parent().removeClass("selected"); $(this).parent().find(":checkbox").removeAttr("checked"); $(this).toggleClass("checkbox-select checkbox-deselect"); } ); }); This works to some extend. The classes toggle just fine, but the rest of the code only works the first time it is run. All subsequent clicks just toggle the class og the link and nothing else. Does anyone have any idea why this is?

    Read the article

  • Jquery draggable + toggleClass problem..

    - by vrynxzent
    the problem here is that the toggleClass position top:0px; left:0px will not trigger.. only the width and height and background-color will activate.. it will work if i will not drag the div(draggable).. if i start to drag the element, the toggled class positioning will not effect.. i dont know if there's such a function in jquery to help this.. <html> <head> <title></title> <script type="text/javascript" src="jquery-1.4.2.js"></script> <script type="text/javascript" src="jquery.ui.core.js"></script> <script type="text/javascript" src="jquery.ui.widget.js"></script> <script type="text/javascript" src="jquery.ui.mouse.js"></script> <script type="text/javascript" src="jquery.ui.resizable.js"></script> <script type="text/javascript" src="jquery.ui.draggable.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#x").draggable().dblclick(function(){ $(this).toggleClass("hi"); }); }); </script> <style> .hello { background:red; width:200px; height:200px; position:relative; top:100px; left:100px; } .hi { background:yellow; position:relative; width:300px; height:300px; top:0px; left:0px; } </style> </head> <body> <div id="x" class="hello"> </div> </body> </html>

    Read the article

  • jquery animated buttons that just wont behave

    - by TJ Sherrill
    Ok I have a inline list of buttons. <ul id="nav"> <li class="home"><a href="#">Menu Item</a></li> <li class="contact"><a href="#">Menu Item</a></li> <li class="about"><a href="#">Menu Item</a></li> </ul> .home{ position:absolute; bottom:0; background-image:url(../img/menu/single_line.png); background-repeat:no-repeat; height:34px; width:134px; } .home_hover{ position:absolute; bottom:0; background-image:url(../img/menu/single_line_over.png); background-repeat:no-repeat; height:70px; width:134px; } $(document).ready(function(){ $("#nav .home").mouseover(function(){ $(this).toggleClass("home_hover").slideToggle("slow"); return false; }).mouseout(function(){ $(this).toggleClass("home_hover").slideToggle("slow"); return false; }); }); Each menu item has a background image, and then when its hovered the background image is replaced by a taller image. Ultimately I am trying to build a simple menu where on mouseover the menu item appears to slide up. But in reality Jquery can animate the toggleClass with slideToggle. The problem is that this current code doesn't behave right. It jumps up and down, because the text is moving. I am pretty new to Jquery so any help is greatly appreciated. I also loaded this up at http://gasworks.ravennainteractive.com/result/ thanks

    Read the article

  • Jquery if statement help

    - by mtwallet
    Hi. I want to know how to correctly write an if statement with jquery. I have a bunch of div's with an anchor in each that when clicked expands the the div's width using toggleClass. This works fine but I want to write an if statement that checks to see if the other div's have the same class applied, if so contract that div, then expand the next div (hope that makes sense), my code so far: HTML: <div class="content-block"> <h2>Title</h2> <p>Content...</p> <a class="expand" href="#">Expand View</a> </div> <div class="content-block"> <h2>Title</h2> <p>Content...</p> <a class="expand" href="#">Expand View</a> </div> <div class="content-block"> <h2>Title</h2> <p>Content...</p> <a class="expand" href="#">Expand View</a> </div> <div class="content-block"> <h2>Title</h2> <p>Content...</p> <a class="expand" href="#">Expand View</a> </div> JQUERY: $(document).ready(function(){ $('a.expand').click(function(){ $(this).parent('.content-block').toggleClass('wide'); }); });

    Read the article

  • How to make an Inputfield change its design when active?

    - by Opoe
    Hi all, Let's say my background color is red. I want the input textfield to appear red, but when you click inside the input field to type it becomes a regulad textfield. And ofcourse when you are not active in the input field it should be back to its original state (red). Its actually something you see quite often. I thought of using toggleclass? My input fields are all appended with jQuery Thanks in advance

    Read the article

  • on click checkbox set input attr

    - by Tommy Arnold
    html form with 4 columns the first 2 columns are the sizes inside input boxes with disabled ='disabled', when they click radio button to select a size a checkbox appears, when they click that checkbox I would like to change the class and disabled attr of the inputs on that table row to allow them to edit the input box <table width="388" border="1" id="product1"> <tr> <td width="100">Width</td> <td width="100">Height</td> <td width="48">Price</td> <td width="65">Select</td> </tr> <tr> <td><input type="text" disabled='disabled'value="200"/><span> CMS</span></td> <td><input disabled='disabled'type="text" value="500"/><span> CMS</span></td> <td>£50.00</td> <td><input type="radio" name="product1" value="size1" /> Customise<input type="checkbox" name="custom[size1]" class="custombox" value="1"/></td> </tr> <tr> <td>200</td> <td>1000</td> <td>£100.00</td> <td><input type="radio" name="product1" value="size2" /> Customise<input disabled='disabled' type="checkbox" name="custom[size2]" class="custombox" value="1"/></td> </tr> <tr> <td>200</td> <td>1500</td> <td>£150</td> <td><input type="radio" name="product1" value="size3" /> Customise<input type="checkbox" name="custom[size3]" class="custombox" value="1"/></td> </tr> </table> <table width="288" border="1" id="product2"> <tr> <td width="72">Width</td> <td width="75">Height</td> <td width="48">Price</td> <td width="65">&nbsp;</td> </tr> <tr> <td>200</td> <td>500</td> <td>£50.00</td> <td><input type="radio" name="product2" value="size1" /> Customise<input type="checkbox" name="custom[size1]" class="custombox" value="1"/></td> </tr> <tr> <td>200</td> <td>1000</td> <td>£100.00</td> <td><input type="radio" name="product2" value="size2" /> Customise<input type="checkbox" name="custom[size2]" class="custombox" value="1"/></td> </tr> <tr> <td>200</td> <td>1500</td> <td>£150</td> <td><input type="radio" name="product2" value="size3" /> Customise<input type="checkbox" name="custom[size3]" class="custombox" value="1"/></td> </tr> <table> CSS input[type=checkbox] { display: none; } input[type=checkbox].shown { display: inline; } input .edit{ border:1px solid red; } input[disabled='disabled'] { border:0px; width:60px; padding:5px; float:left; background:#fff; } span{float:left; width:30px; padding:5px;} Jquery $("body :checkbox").hide(); // The most obvious way is to set radio-button click handlers for each table separatly: $("#product1 :radio").click(function() { $("#product1 :checkbox").hide(); $("#product1 .cbox").hide(); $(this).parent().children(":checkbox").show(); $(this).parent().children(".cbox").show(); }); $("#product2 :radio").click(function() { $("#product2 :checkbox").hide(); $("#product2 .cbox").hide(); $(this).parent().children(":checkbox").show(); $(this).parent().children(".cbox").show(); }); This is what I thought but its not working $("#product1 :checkbox").click(function(){ $(this).parent("tr").children("td :input").attr('disabled',''); $(this).parent("tr").children("td :input").toggleClass(edit); }); $("#product2 :checkbox").click(function(){ $(this).parent("tr").children("td :input").attr('disabled',''); $(this).parent("tr").children("td :input").toggleClass(edit); }); Thanks in advance for any help.

    Read the article

  • Both tab & hover triggered popups problem

    - by carpenter
    I am trying to display divs when hovering over thumb-nails and/or both when tabbing onto them. If I stick to my mouse, the popups seem to work OK - if I start with a tab press I can show the popops also (foward only - no shift + tab yet). Any help getting them to play well together? <script type="text/javascript"> // Note: the below is being run from an onmouseover on a asp:HyperLink at the moment function onhovering_and_tabbingon2() { var active_hover = 0; var num_of_thumb; // set the default focus onto the first thumb-nail and make its popup display document.getElementById('link_no' + active_hover).focus(); // set focus on the first thumb $('#pop' + active_hover).toggleClass('popup'); // show its popup as it is hidden // for when hovering over the thumbs $(".box img").hover( // so as to effect only images/thumb-nails within divs of class=box when hovering over them function () { // test for if the image is a thumb-entry and not a popup image - of class=thumbs2 thumb = $(this).attr('class'); if (thumb != "thumbs2") { // I need to add/toggle the class here to a "div" and not to the image being hovered on, a div with text that corrosponds to the hovered on image though // so grab the number of the thumb_entry - to use to id the div. num_of_thumb = $(this).attr('id').replace('thumb_entry_No', ''); // find the div with id 'pop' + num_of_thumb, and toggleClass on it $('#pop' + num_of_thumb).toggleClass('popup'); // shows the hovered on pic's popup // move the focus to the hovered on pic's a tag ?????? document.getElementById('link_no' + num_of_thumb).focus(); // if the previous popup that was showing was in box2.. if (active_hover == 1 || active_hover% 2 == 1) { $('#pop' + active_hover).toggleClass('popup4_line2'); } else { // remove/toggle the previous active popup's visibility $('#pop' + active_hover).toggleClass('popup'); } // set the new active_hover to num_of_thumb active_hover = num_of_thumb; } }, function () { } ); // same thing again - but for my second row/line of entries/thumb-nails... $(".box2 img").hover( // so as to effect only images/thumbs within divs of class=box2 function () { // test if the image is a thumb-entry and not a popup image thumb = $(this).attr('class'); if (thumb != "thumbs2") { // I need to add the class here to a "div" and not to the image being hovered on, a div that corrosponds to the hovered on image though // so grab the number of the thumb_entry being hovered on, so as to id the div. num_of_thumb = $(this).attr('id').replace('thumb_entry_No', ''); // find the div with id='pop' + num_of_thumb, and toggleClass on it $('#pop' + num_of_thumb).toggleClass('popup4_line2'); // move the focus to the hovered on pic's a tag ?? document.getElementById('link_no' + num_of_thumb).focus(); // if the previous popup that was showing was in box.. // or if the active_hover is even (modulus) if (active_hover == 0 || active_hover % 2 == 0) { $('#pop' + active_hover).toggleClass('popup'); } else { // remove the previous active visible popup $('#pop' + active_hover).toggleClass('popup4_line2'); } // set the new active_hover to num_of_thumb active_hover = num_of_thumb; } }, function () { } ); // todo: I would like to try to show the popups when tabbing through the thumb-nails also // but am lost... document.onkeyup = keypress; // ???? function keypress() { // alert("The key pressed was: " + window.event.keyCode); if (window.event.keyCode == "9") { //alert("The tab key was pressed!"); active_hover = active_hover + 1; // for tabbing into box 2 (odd numbers) if (active_hover == 1 || active_hover % 2 == 1) { // toggle visibility of previous popup $('#pop' + (active_hover - 1)).toggleClass('popup'); // toggle visibility of current popup $('#pop' + active_hover).toggleClass('popup4_line2'); // } else { // for tabbing into box from box2 // toggle visibility of previous popup $('#pop' + (active_hover - 1)).toggleClass('popup4_line2'); // toggle visibility of current popup $('#pop' + active_hover).toggleClass('popup'); // } // ?????? // // if (window.event.keyCode == "shift&9") { } } } } </script>

    Read the article

  • Changing class of h2 inside specific div

    - by user1985060
    I want to make it so that everytime you click on an 'h2' tag, the 'input' inside gets selected and the 'h2' tag changes background, but if another 'h2' tag is clicked, the current highlight and 'input' selection changes accordingly. problem is that I have 3 different that do the same and with my code all the 3 forms are affected rather one. How do i limit my changes to only be contained to that form. Here is some code for clarification ' <form> ... <h2 onclick="document.getElementById(1001).checked='True' $('h2').removeClass('selected'); $(this).addClass('selected'); "> CONTENT <input type="radio" name="radio" id="1001" value="1001" /> </h2> ... </form>

    Read the article

  • A smarter way to do this jQuery?

    - by Nicky Christensen
    I have a a map on my site, and clicking regions a class should be toggled, on both hover and click, I've made a jQuery solution to do this, however, I think it can be done a bit smarter than i've done it? my HTML output is this: <div class="mapdk"> <a data-class="nordjylland" class="nordjylland" href="#"><span>Nordjylland</span></a> <a data-class="midtjylland" class="midtjylland" href="#"><span>Midtjylland</span></a> <a data-class="syddanmark" class="syddanmark" href="#"><span>Syddanmark</span></a> <a data-class="sjaelland" class="sjalland" href="#"><span>Sjælland</span></a> <a data-class="hovedstaden" class="hovedstaden" href="#"><span>Hovedstaden</span></a> </div> And my jQuery looks like: if ($jq(".area .mapdk").length) { $jq(".mapdk a.nordjylland").hover(function () { $jq(".mapdk").toggleClass("nordjylland"); }).click(function () { $jq(".mapdk").toggleClass("nordjylland"); }); $jq(".mapdk a.midtjylland").hover(function () { $jq(".mapdk").toggleClass("midtjylland"); }).click(function () { $jq(".mapdk").toggleClass("midtjylland"); }); } The thing is, that with what i've done, i have to make a hover and click function for every link i've got - I was thinking I might could keep it in one hover,click function, and then use something like $jq(this) ? But not sure how ?

    Read the article

  • Highlight multiple rows using jQuery

    - by cf_PhillipSenn
    I'm putting together a succinct jQuery matrix because I'm having a hard time navigating around on the jQuery site, and the cheat sheets don't seem to provide me what I want either. Here's how I highlight the rows: $('.eq').hover(function() { $('.eq').toggleClass('highlight'); }); $('.is').hover(function() { $('.is').toggleClass('highlight'); }); Q: How can I write a function that says "toggle everything in the same class as what is being hovered over"? Something like: function toggle(that){ $(that.className).toggleClass('highlight'); }

    Read the article

  • jQuery toggle caching / cookies

    - by user1706680
    I’m using the jQuery toggle function for my navigation. By default the Authors toggle is visible, the Archives toggle is closed. http://jsfiddle.net/TeDFs/4/ My problem is that when the users switches to another page the toggles reset themselves. For example, when the user closes the Authors toggle and opens the Archive toggle and then navigates to another page the default settings are loaded. I read that it’s possible to store the settings via cookies but I’m absolutely new to jQuery and it would be great if somebody could help me out! HTML <div id="authors" class="widget"> <h2 class="widget-title-visible">Authors</h2> <div class="toggle"> <div class="submenu"> <ul> <li>Name 1</li> <li>Name 2</li> <li>Name 3</li> <li>Name 3</li> </ul> </div> </div> <div id="archives" class="widget"> <h2 class="widget-title">Archiv</h2> <div class="toggle hidden"> <div class="submenu"> <ul> <li>November 2012</li> <li>Oktober 2012</li> </ul> </div> </div> </div>? jQuery function toggleWidgets() { jQuery('.widget-title').addClass('plus'); jQuery('.widget-title-visible').addClass('minus'); jQuery('.widget-title').click(function() { $(this).toggleClass('plus').toggleClass('minus').next().toggle(180); }); jQuery('.widget-title-visible').click(function() { $(this).toggleClass('minus').toggleClass('plus').next().toggle(180); }); } jQuery(document).ready(function() { toggleWidgets(); } )? CSS .hidden{ display:none; } .plus { background: url(http://moargh.de/daten/sidebar_arrows.png) 0 5px no-repeat; padding: 0 0 0 12px; } .minus { background: url(http://moargh.de/daten/sidebar_arrows.png) 0 -10px no-repeat; padding: 0 0 0 12px; }

    Read the article

  • jQuery filter() traversing doesnt seems to work ??

    - by atif089
    I dont know what is the problem with this ? $('.post').live('mouseenter mouseleave', function() { $(this).filter('anything here,a,div,.class,#id').toggleClass('hidden'); }); where as this works fine. $('.post').live('mouseenter mouseleave', function() { $(this).toggleClass('hidden'); }); There is an anchor which I would like to show on mouse hover. Similar to Facebook

    Read the article

  • Unable to Click a row and call javascript function?

    - by user2807977
    I'm unable to trigger $(this).toggleClass('selected'); for content table. When I debug it just skip this event. How can I make sure its being selected? $('#contentChangesTable tr') .filter(':has(:checkbox:checked)') .addClass('selected') .end() .click(function (event) { $(this).toggleClass('selected'); if (event.target.type !== 'checkbox') { $(':checkbox', this).attr('checked', function () { return !this.checked; }); } });

    Read the article

  • jquery animate - dead simple

    - by danit
    All I want to do is on .click() is .animate #slip, essentially Im changing the css at the moment from top: 10px to top: 0px Instead of it being quite clunky i'd like to animate the movement on the change of CSS. Currently use .toggleClass to achieve this: $("#div1").click(function() { $("#div2t").toggleClass('min'); });

    Read the article

  • Tips on how to refactor this unwieldy upvote/downvote code

    - by bob_cobb
    Basically this code is for an upvote/downvote system and I'm basically Incrementing the count by 1 when voting up Decrementing the count by 1 when voting down If the number of downvotes upvotes, we'll assume it's a negative score, so the count stays 0 Reverting the count back to what it originally was when clicking upvote twice or downvote twice Never go below 0 (by showing negative numbers); Basically it's the same scoring scheme reddit uses, and I tried to get some ideas from the source which was minified and kind of hard to grok: a.fn.vote = function(b, c, e, j) { if (reddit.logged && a(this).hasClass("arrow")) { var k = a(this).hasClass("up") ? 1 : a(this).hasClass("down") ? -1 : 0, v = a(this).all_things_by_id(), p = v.children().not(".child").find(".arrow"), q = k == 1 ? "up" : "upmod"; p.filter("." + q).removeClass(q).addClass(k == 1 ? "upmod" : "up"); q = k == -1 ? "down" : "downmod"; p.filter("." + q).removeClass(q).addClass(k == -1 ? "downmod" : "down"); reddit.logged && (v.each(function() { var b = a(this).find(".entry:first, .midcol:first"); k > 0 ? b.addClass("likes").removeClass("dislikes unvoted") : k < 0 ? b.addClass("dislikes").removeClass("likes unvoted") : b.addClass("unvoted").removeClass("likes dislikes") }), a.defined(j) || (j = v.filter(":first").thing_id(), b += e ? "" : "-" + j, a.request("vote", {id: j,dir: k,vh: b}))); c && c(v, k) } }; I'm trying to look for a pattern, but there are a bunch of edge cases that I've been adding in, and it's still a little off. My code (and fiddle): $(function() { var down = $('.vote-down'); var up = $('.vote-up'); var direction = up.add(down); var largeCount = $('#js-large-count'); var totalUp = $('#js-total-up'); var totalDown = $('#js-total-down'); var totalUpCount = parseInt(totalUp.text(), 10); var totalDownCount = parseInt(totalDown.text(), 10); var castVote = function(submissionId, voteType) { /* var postURL = '/vote'; $.post(postURL, { submissionId : submissionId, voteType : voteType } , function (data){ if (data.response === 'success') { totalDown.text(data.downvotes); totalUp.text(data.upvotes); } }, 'json'); */ alert('voted!'); }; $(direction).on('click', direction, function () { // The submission ID var $that = $(this), submissionId = $that.attr('id'), voteType = $that.attr('dir'), // what direction was voted? [up or down] isDown = $that.hasClass('down'), isUp = $that.hasClass('up'), curVotes = parseInt($that.parent().find('div.count').text(), 10); // current vote castVote(submissionId, voteType); // Voted up on submission if (voteType === 'up') { var alreadyVotedUp = $that.hasClass('likes'), upCount = $that.next('div.count'), dislikes = $that.nextAll('a').first(); // next anchor attr if (alreadyVotedUp) { // Clicked the up arrow and previously voted up $that.toggleClass('likes up'); if (totalUpCount > totalDownCount) { upCount.text(curVotes - 1); largeCount.text(curVotes - 1); } else { upCount.text(0); largeCount.text(0); } upCount.css('color', '#555').hide().fadeIn(); largeCount.hide().fadeIn(); } else if (dislikes.hasClass('dislikes')) { // Voted down now are voting up if (totalDownCount > totalUpCount) { upCount.text(0); largeCount.text(0); } else if (totalUpCount > totalDownCount) { console.log(totalDownCount); console.log(totalUpCount); if (totalDownCount === 0) { upCount.text(curVotes + 1); largeCount.text(curVotes + 1); } else { upCount.text(curVotes + 2); largeCount.text(curVotes + 2); } } else { upCount.text(curVotes + 1); largeCount.text(curVotes + 1); } dislikes.toggleClass('down dislikes'); upCount.css('color', '#296394').hide().fadeIn(200); largeCount.hide().fadeIn(); } else { if (totalDownCount > totalUpCount) { upCount.text(0); largeCount.text(0); } else { // They clicked the up arrow and haven't voted up yet upCount.text(curVotes + 1); largeCount.text(curVotes + 1).hide().fadeIn(200); upCount.css('color', '#296394').hide().fadeIn(200); } } // Change arrow to dark blue if (isUp) { $that.toggleClass('up likes'); } } // Voted down on submission if (voteType === 'down') { var alreadyVotedDown = $that.hasClass('dislikes'), downCount = $that.prev('div.count'); // Get previous anchor attribute var likes = $that.prevAll('a').first(); if (alreadyVotedDown) { if (curVotes === 0) { if (totalDownCount > totalUp) { downCount.text(curVotes); largeCount.text(curVotes); } else { if (totalUpCount < totalDownCount || totalUpCount == totalDownCount) { downCount.text(0); largeCount.text(0); } else { downCount.text((totalUpCount - totalUpCount) + 1); largeCount.text((totalUpCount - totalUpCount) + 1); } } } else { downCount.text(curVotes + 1); largeCount.text(curVotes + 1); } $that.toggleClass('down dislikes'); downCount.css('color', '#555').hide().fadeIn(200); largeCount.hide().fadeIn(); } else if (likes.hasClass('likes')) { // They voted up from 0, and now are voting down if (curVotes <= 1) { downCount.text(0); largeCount.text(0); } else { // They voted up, now they are voting down (from a number > 0) downCount.text(curVotes - 2); largeCount.text(curVotes - 2); } likes.toggleClass('up likes'); downCount.css('color', '#ba2a2a').hide().fadeIn(200); largeCount.hide().fadeIn(200); } else { if (curVotes > 0) { downCount.text(curVotes - 1); largeCount.text(curVotes - 1); } else { downCount.text(curVotes); largeCount.text(curVotes); } downCount.css('color', '#ba2a2a').hide().fadeIn(200); largeCount.hide().fadeIn(200); } // Change the arrow to red if (isDown) { $that.toggleClass('down dislikes'); } } return false; }); });? Pretty convoluted, right? Is there a way to do something similar but in about 1/3 of the code I've written? After attempting to re-write it, I find myself doing the same thing so I just gave up halfway through and decided to ask for some help (fiddle of most recent).

    Read the article

  • Toggle two divs and classes

    - by kuswantin
    I have two links with classes (login-form and register-form) relevant to their target forms ID, they want to toggle. I have also a predefined 'slideToggle' function to toggle better. This is what I have tried so far: $('#userbar a').click(function() { var c = $(this).attr('class'); $('#userbar a').removeClass('active'); $(this).toggleClass('active'); $('#register-form,#login-form').hide(); //bad, causing flashy $('#' + c).slideToggle('slow'); return false; }); With this I have trouble with the flashy window, and to correctly toggle the active classes when another link is clicked, the other link should not have active class anymore. Additional problem is the link is dead on serial clicks. I have another try, longer one: $('#userbar a').click(function() { var c = $(this).attr('class'); switch (c) { case 'login-form': $('#' + c).slideToggle('slow'); $(this).toggleClass('active'); $('#register-form').hide(); break; case 'register-form': $('#' + c).slideToggle('slow'); $(this).toggleClass('active'); $('#login-form').hide(); break; } return false; }); This one is worse than the first :( Any suggestion to correct the behavior? What I want is when a link with class login-form is click, so toggle the form with ID login-form, and hide the register-form if open. Any help would be very much appreciated. Thanks.

    Read the article

  • .attr("disabled", "disabled") problem

    - by meo
    i have this function where basically add and remove the disabled attribute form a input field: $(bla).click(function(){ if (something) { console.log($target.prev("input")) // gives out the right object $target.toggleClass("open").prev("input").attr("disabled", "disabled"); }else{ $target.toggleClass("open").prev("input").removeAttr("disabled"); //this works } }) the removeAttr works fine but when i need to add the disabled again it does just nothing. My console.log is triggering (and giving me back the right input field) so I'm sure my that my if statement works. But if i inspect the DOM with firebug the disabled attribute does not appear. can someone help me? PS: please don't focus on the function or the if statement itself, works fine its just that attr that dies not work for disabled...

    Read the article

  • Add remove class?

    - by Steven
    Okay I have two classes for two links and two divs with different information. What I am trying to do is have it so when you click on one link it adds a 2 to both of the classes and makes the second div visable. When you click on the other link it takes off a 2 and makes the first div visable. Here is what I currently got $("#posts").click(function () { $("#sideboxtopleft").toggleClass("2"); $("#arrow").toggleClass("2"); }); Pretty much posts is the link, when when you click on it. It would make sideboxtopleft and arrow, sideboxtopleft2 and arrow2 and when you clicked on comments it would take off the 2 of both of those. Then there are two divs, one is set to hidden and I want to make it visable and set the other to hidden. Pretty much creating a tab system with changing tab classes.

    Read the article

  • how to use trigger in Jquery to pass parameter data as well as control (this)

    - by Shantanu Gupta
    I am trying to use same validation funtion for all my controls. But I dont know much in jquery and not been able to pass event handler to the trigger. I want to pass textbox id to my custom function. How can i do this <script src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#txtFirstName").bind('focusout', function() { $(this).trigger("customblurfocus",[$(this).val(), $(this).val() + " Required !", "Ok !"]); } ); $(this).bind('customblurfocus',function(defaultInputValue,ErrorMessage,ValidMessage) {alert($(this).val()); if($(this).val()=="" || $(this).val()==defaultInputValue) { $(this).val(defaultInputValue); $(this).siblings("span[id*='error']").toggleClass("error_set").text(ErrorMessage).fadeOut(3000); } else { $(this).siblings("span[id*='error']").toggleClass("error_ok").text(ValidMessage).show(1000); } } ); }); </script>

    Read the article

  • Switching layouts page jumping (improvement to script)

    - by Ricardo Zea
    Hello, I'm using this script to switch layouts in a page: $("span.switcher").click(function () { $("span.switcher").toggleClass("swap"); /*!*/ $("ol.search-results").fadeOut("fast", function() { $(this).fadeIn("fast").toggleClass("grid"); }); The script works fine, the problem I have is that if the switch view is down the page, the layout changes and then the page jumps back up. If I add 'return false' right where you see the /* ! */ in the second line the script doesn't work. Also, as you can see, I'm using < span instead of < a since I was told that using other element other than < a would stop the page from jumping. Any idea how to fix the jumping of the page? Thanks.

    Read the article

  • jquery slide toggle divs without creating multiple classes, functions, etc... ui accordion

    - by SPE
    Greetings, based on the jquery ui accordion I'm using, I have added a slide toggle to my accordion list items. so what happens is I click on an li and a div slides down underneath to reveal more content. The issue I'm having is that I find myself having to create multiple id's to reference the slidetoggle. example of the div id css: #panel, #panel2, #panel3, #panel4, etc.... the Is there a way I can use the slide toggle without having to adding another number so it will slide? I have 50 list items I'm using: Here's a sample of the js (as you can see where I'm going with this): $(".btn-slide").click(function(){ $("#panel").slideToggle("slow"); $(this).toggleClass("active"); return false; }); $(".btn-slide2").click(function(){ $("#panel2").slideToggle("slow"); $(this).toggleClass("active"); return false; }); sample html: <li><div class="slide"><a href="#" class="btn-slide">One</a></div><div id="panel"></div></li> <li><div class="slide"><a href="#" class="btn-slide2">Two</a></div><div id="panel2"></div></li>

    Read the article

  • Jquery class changing works, but doesn't effect another function like it should

    - by Qwibble
    So I have content boxes that close and expand when you click an arrow. The content box has two classes for telling whether it is open or closed (.box_open, .box_closed). A hover function is assigned to box_open so when it is open and you hover over the header, the arrow appears. However, I don't want this to happen when the box is closed, as I want to arrow to remain visible when the box is closed. When the box closes, the box_open class is removed, but the function assigned to that class still works. Here's the jquery code for the two functions. You can also see them in the head of the demo below. // Display Arrow on Box Header Hover $(".box_open").hover( function () { $(this).find('a').show(); }, function () { $(this).find('a').hide(); } ); // Open and Close Boxes: $(".box_header a").click( function () { $(this).parent().next('.box_border').stop().toggle(); $(this).parent().toggleClass("box_open"); $(this).parent().toggleClass("box_closed"); return false; } ); Can anyone take a look at what the problem is? Here's the demo url: Demo Url

    Read the article

1 2 3 4  | Next Page >