Search Results

Search found 482 results on 20 pages for 'removeclass'.

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

  • Jquery – Disable/unbind click on active items, rebind click when inactive

    - by j-man86
    I have a left-positioned navigation that shows/hides content on the right. Currently, when you click a link, it fades in the corresponding content on the right and adds an active class to that link. My problem is that if you click the active link again, the content on the right keeps on fading in again. I would like to unbind that click while the link is active, and if you click on another navigation link (subsequently removing the class from the previous link and adding it to the current one) rebind the click event to all inactive links. Here is my current code: $('.mixesSidebar ul li').click( function() { //Get the attribute id var liId = $(this).attr('id'); //removeClass active from all li's, addClass active to this $('.mixesSidebar ul li').removeClass('active'); $(this).addClass('active'); //Hide all content on the right $('.mixesContent ul').hide(); //Find the content with the same class as the clicked li's ID, and fadeIn $('.mixesContent').find('.' + liId).fadeIn('slow'); }); Thanks so much for your help!

    Read the article

  • [jQuery] preload image and show a spinner while loading

    - by robertdd
    Hy, i use uploadify to upload some images, after i display all the images thumbs in a list, when i click on a image thumb a bigger image it's open in a div with this function $(".thumbs li a").click(function(){ var largePath = $(this).attr("href"); $('.thumbs li').removeClass('thumbac'); $(this).parent().addClass('thumbac'); $("#largeImg").attr({ src: largePath }); return false; }); here is my list of photos: <div class="upimage"> <ul id="upimagesQueue" class="thumbs"> <li id="liupimages"> <a href="uploads/0001.jpg"><img src="uploads/0001.jpg" alt="0001.jpg" id=""></a> </li> <li id="liupimages"> <a href="uploads/0002.jpg"><img src="uploads/0002.jpg" alt="0002.jpg" id=""></a> </li> <li id="liupimages"> <a href="uploads/0003.jpg"><img src="uploads/0003.jpg" alt="0003.jpg" id=""></a> </li> <script> $(".thumbs li a").click(function(){ var largePath = $(this).attr("href"); $('.thumbs li').removeClass('thumbac'); $(this).parent().addClass('thumbac'); $("#largeImg").attr({ src: largePath }); return false; }); </script> </ul> </div> this is the div where the images appear <div class="largeImg" > <img id="largeImg" src="" /> </div> how i can preload the image before it display?

    Read the article

  • jQuery addClass on $.post

    - by Tim
    I am basically trying to create a small registration form. If the username is already taken, I want to add the 'red' class, if not then 'green'. The PHP here works fine, and returns either a "YES" or "NO" to determine whether it's ok. The CSS: input { border:1px solid #ccc; } .red { border:1px solid #c00; } .green { border:1px solid green; background:#afdfaf; } The Javascript I'm using is: $("#username").change(function() { var value = $("#username").val(); if(value!= '') { $.post("check.php", { value: value }, function(data){ $("#test").html(data); if(data=='YES') { $("#username").removeClass('red').addClass('green'); } if(data=='NO') { $("#username").removeClass('green').addClass('red'); } }); } }); I've got the document.ready stuff too... It all works fine because the #test div html changes to either "YES" or "NO", apart from the last part where I check what the value of the data is. Here is the php: $value=$_POST['value']; if ($value!="") { $sql="select * FROM users WHERE username='".$value."'"; $query = mysql_query($sql) or die ("Could not match data because ".mysql_error()); $num_rows = mysql_num_rows($query); if ($num_rows 0) { echo "NO"; } else { echo "YES"; } }

    Read the article

  • jQuery not and classes

    - by Giles B
    Hi Guys, I have 2 anchor links (a.selector) and when one is clicked it has a class applied to it of 'active-arrow' and the click also removes the class of the same name from the other anchor as well as lowering the opacity to 0.2. I then want to have a fade effect when the user hovers over the anchor that doesn't have 'active-arrow' applied to it so that it goes to full opacity when mouseenters and back to 0.2 when mouseleaves. The problem im having is that both .not and :not don't seem to be working as expected, the hover effect works but if I click on the anchor whilst hovering the 'active-arrow' class is applied but when mouseleaves the opacity is faded down to 0.2 again even though the 'active-arrow' class is applied. Also the hover then doesn't work for the other a link which has had 'active-arrow' removed. Bit of a hard one to explain so heres some code that hopefully helps a bit. *//If a.selector doesn't have the class 'active-arrow' then run the hoverFade function* $("a.selector").not(".active-arrow").hoverFade(); //Functions for first element $('a.selector-1').click(function () { $('a.selector-2').removeClass('active-arrow'); //Remove background image from corresponding element $('ul#storage-items-2').fadeOut(1200).addClass('hide'); //Fade out then hide corresponding list $(this).addClass('active-arrow', 'fast'); //Add background image to current element $('ul#storage-items-1').removeClass('hide').fadeIn(1800); //Unhide and fade in the list $('a.selector-2').fadeTo(500, 0.2); //Fade corresponding element $(this).fadeTo(800, 1);//Fade this element to full opacity }); I only included the code for teh first anchor (a.selector-1) as the code for the second anchor is identical but just changes the class names to a.selector-2. Also the hoverFade function is in a seperate file so we can re-use it. jQuery.fn.hoverFade = function() { return this.each(function(){ $(this).hover( function () { $(this).fadeTo(500, 0.8); }, function () { $(this).fadeTo(500, 0.2); }); }); } Each anchor link fades in and fades out a UL as well. Any help is most appreciated Thanks Giles

    Read the article

  • Showing right sub-ul of parent ul menu

    - by Micke
    Hello, i have this html menu: <ul id='main'> <li class='active current' id='lighty'> <a href='/'>Lighty</a> <ul> <li class='sub'> <a href='/'>Hem</a> </li> </ul> </li> <li id='community'> <a href='/community'>Community</a> </li> </ul> And this jquery: $("#menu ul > li").mouseenter(function(){ id = $(this).attr("id"); $("#menu #main li").removeClass("active"); $(this).addClass("active"); }).mouseleave(function(){ id = $(this).attr("id"); menu.timers[id] = setTimeout(function(){$("#menu #main li#"+id).removeClass("active");}, 2000); }); What i am trying to acomplish is that when i hover one of the li's in the main ul the child ul of that li should be displayed. and when i move the mouse out of the li or the child ul the menu should be visible for 2 seconds. It works through the main li button but if on the child ul and move out it just disapears, it doesnt wait for two seconds. The waiting two seconds is so you can go in to the menu if you accidentaly move the mouse out of it. Can anybody help me to fix this error? Maybe you have a better solution? Here is also a screenshot on how the menu looks if it helps: screen shot under or click here

    Read the article

  • Help with pregreplace and uniqid for jquery dialog boxes

    - by Scarface
    First of all, do not be overwhelmed by the long code, I just put it for reference...I have a function that runs preg_replace on each comment users post and puts matches in a jquery dialog box with a matching open-link. For example, if there is a paragraph with two matches, they will be put inside two divs, and a jquery dialog function will be echoed twice; one for each div. While this works for one match, if there are multiple matches, it does not. I am not sure how to distribute unique ids at a point in time for each of the divs and matching dialog open-scripts. Keep in mind, I removed the preg replace function since it kind of complicates the problem. If anyone has any ideas, they will be greatly appreciated. <?php $id=uniqid(); $id2=uniqid(); echo "<div id=\"$id2\"> </div>"; ?> $.ui.dialog.defaults.bgiframe = true; $(function() { $("<?php echo"#$id2"; ?>").dialog({hide: 'clip', modal: true ,width: 600,height: 350,position: 'center', show: 'clip',stack: true,title: 'title', minHeight: 25, minWidth: 100, autoOpen: false}); $('<?php echo"#$id"; ?>').click(function() { $('<?php echo"#$id2"; ?>').dialog('open'); }) .hover( function(){ $(this).addClass("ui-state-hover"); }, function(){ $(this).removeClass("ui-state-hover"); } ).mousedown(function(){ $(this).addClass("ui-state-active"); }) .mouseup(function(){ $(this).removeClass("ui-state-active"); }); });

    Read the article

  • jQuery plugin Tablesorter 2.0 behaves weird

    - by gunther-von-goetzen-sanchez
    I downloaded the jQuery plugin Tablesorter 2.0 from http://tablesorter.com/jquery.tablesorter.zip and modified the example-pager.html which is in tablesorter/docs directory I wrote additional Rollover effects: $(function() { $("table") .tablesorter({widthFixed: true, widgets: ['zebra']}) .tablesorterPager({container: $("#pager")}); /** Additional code */ $("tr").mouseover(function () { $(this).addClass('over'); }); $("tr").mouseout(function () { $(this).removeClass('over'); }); $("tr").click(function () { $(this).addClass('marked'); }); $("tr").dblclick(function () { $(this).removeClass('marked'); }); /** Additional code END */ }); And of course modified the themes/blue/style.css file: /* Additional code */ table.tablesorter tbody tr.odd td { background-color: #D1D1F0; } table.tablesorter tbody tr.even td { background-color: #EFDEDE; } table.tablesorter tbody tr.over td { background-color: #FBCA33; } table.tablesorter tbody tr.marked td { background-color: #FB4133; } /* Additional code END*/ All this works fine BUT when I go to further pages i.e. page 2 3 or 4 the effects are gone! I really appreciate your help

    Read the article

  • jQuery accordion - different image for active sections

    - by Andrew Cassidy
    Hi, I'm using Ryan Stemkoski's "Stupid Simple Jquery Accordion Menu" which is available here: stemkoski.com/stupid-simple-jquery-accordion-menu/ Here is the javascript $(document).ready(function() { //ACCORDION BUTTON ACTION (ON CLICK DO THE FOLLOWING) $('.accordionButton').click(function() { //REMOVE THE ON CLASS FROM ALL BUTTONS $('.accordionButton').removeClass('on'); //NO MATTER WHAT WE CLOSE ALL OPEN SLIDES $('.accordionContent').slideUp('normal'); //IF THE NEXT SLIDE WASN'T OPEN THEN OPEN IT if($(this).next().is(':hidden') == true) { //ADD THE ON CLASS TO THE BUTTON $(this).addClass('on'); //OPEN THE SLIDE $(this).next().slideDown('normal'); } }); /*** REMOVE IF MOUSEOVER IS NOT REQUIRED ***/ //ADDS THE .OVER CLASS FROM THE STYLESHEET ON MOUSEOVER $('.accordionButton').mouseover(function() { $(this).addClass('over'); //ON MOUSEOUT REMOVE THE OVER CLASS }).mouseout(function() { $(this).removeClass('over'); }); /*** END REMOVE IF MOUSEOVER IS NOT REQUIRED ***/ /******************************************************************************************************************** CLOSES ALL S ON PAGE LOAD ********************************************************************************************************************/ $('.accordionContent').hide(); }); and the CSS #wrapper { width: 800px; margin-left: auto; margin-right: auto; } .accordionButton { width: 800px; float: left; _float: none; /* Float works in all browsers but IE6 */ background: #003366; border-bottom: 1px solid #FFFFFF; cursor: pointer; } .accordionContent { width: 800px; float: left; _float: none; /* Float works in all browsers but IE6 */ background: #95B1CE; } /*********************************************************************************************************************** EXTRA STYLES ADDED FOR MOUSEOVER / ACTIVE EVENTS ************************************************************************************************************************/ .on { background: #990000; } .over { background: #CCCCCC; } There is an "on" class which allows the style of the accordionButton class when it is active but I would like to be able to have each active accordionButton class have a different image. http://www.thepool.ie For example, in the above site the word "WORK" should be a darker grey image when the work section is selected, so should COLLAB when it is selected etc. I can't figure out how to do this, any help would be greatly appreciated. Thanks, Andrew

    Read the article

  • Problems with jQuery plugin Tablesorter 2.0

    - by gunther-von-goetzen-sanchez
    I downloaded the jQuery plugin Tablesorter 2.0 from http://tablesorter.com/jquery.tablesorter.zip and modified the example-pager.html which is in tablesorter/docs directory I wrote additional Rollover effects: $(function() { $("table") .tablesorter({widthFixed: true, widgets: ['zebra']}) .tablesorterPager({container: $("#pager")}); $("tr").mouseover(function () { $(this).addClass('over'); }); $("tr").mouseout(function () { $(this).removeClass('over'); }); $("tr").click(function () { $(this).addClass('marked'); }); $("tr").dblclick(function () { $(this).removeClass('marked'); }); }); And of course modified the themes/blue/style.css file: /* Additional code */ table.tablesorter tbody tr.odd td { background-color: #D1D1F0; } table.tablesorter tbody tr.even td { background-color: #EFDEDE; } table.tablesorter tbody tr.over td { background-color: #FBCA33; } table.tablesorter tbody tr.marked td { background-color: #FB4133; } /* Additional code END*/ All this works fine BUT when I go to further pages i.e. page 2 3 or 4 the effects are gone! I really appreciate your help

    Read the article

  • Coda Slider scroll effect. Click button and change panel.

    - by vatismarty
    <?php echo $javascript->link('jquery-easing-1.3.pack'); ?> <?php echo $javascript->link('jquery-easing-compatibility.1.2.pack'); ?> <?php echo $javascript->link('coda-slider.1.1.1.pack'); ?> <script type="text/javascript"> var theInt = null; var $crosslink, $navthumb; var curclicked = 0; theInterval = function(cur){ clearInterval(theInt); if( typeof cur != 'undefined' ) curclicked = cur; $crosslink.removeClass("active-thumb"); $navthumb.eq(curclicked).parent().addClass("active-thumb"); $(".stripNav ul li a").eq(curclicked).trigger('click'); theInt = setInterval(function(){ $crosslink.removeClass("active-thumb"); $navthumb.eq(curclicked).parent().addClass("active-thumb"); $(".stripNav ul li a").eq(curclicked).trigger('click'); curclicked++; if( 6 == curclicked ) curclicked = 0; }, 3000); }; $(function(){ $("#main-photo-slider").codaSlider(); $navthumb = $(".nav-thumb"); $crosslink = $(".cross-link"); $navthumb .click(function() { var $this = $(this); theInterval($this.parent().attr('href').slice(1) - 1); return false; }); theInterval(); $(".stripViewer").mouseover(function(e) { $(this).stop(); }); }); </script> The actual slider is in this page. PROBLEM : The slider does not work when i click on the 2, 3, and 4th buttons. 1st button shows weird behaviour. Please help me fix this bug. The slider should take me to panel 3 if i click button 3

    Read the article

  • Coloring text with css using jQuery

    - by ArtWorkAD
    Hi, I have a little problem adding a class to a span element and so coloring it in order to perform simple validation. Here is my js: function validateKey(){ var length = $('#appkey').val().length; if(length != 8){ $('#appkey').addClass('error'); $('#appKeyInfo').addClass('error'); return false; }else{ $('#appkey').removeClass('error'); $('#appKeyInfo').removeClass('error'); return true; } } And html: <label>KEY</label></br> <input type="text" id="appkey" value=""/></br> <span id="appKeyInfo">Dein App-Key aus 8 Ziffern</span> And the jsfiddle: example Any ideas? UPDATE: coloring of appKeyInfo fails, coloring appkey works. When I remove color:red and type font-weight:bold instead the text is bold on error. when I remove color definition of appKeyInfo the text can be colored red on error, strange thing, but I need a font color for the appKeyInfo

    Read the article

  • jQuery tabs - multiple sets on on page

    - by Jonny Wood
    This is kind of a follow on from a previous question I posted but I've not been able to get it to work.. I'm trying to use multiple sets of tabs (jQuery) on one page. This is the code I had for one set of tabs which works great: $('div.tabs div.tab').hide(); $('div.tabs div:first').show(); $('div.tabs ul.htabs li:first a').addClass('current'); $('div.tabs ul.htabs li a').click(function(){ $('div.tabs ul.htabs li a').removeClass('current'); $(this).addClass('current'); var currentTab = $(this).attr('href'); $('div.tabs div.tab').hide(); $(currentTab).show(); return false; }); To use more than one set on the page I assigned #id's to each tab-set and tried to impliment this with: $.each(['#tabs-1', '#tabs-2', '#tabs-3' ], function(id) { $(id + 'div.tab').hide(); $(id + 'div:first').show(); $(id + 'ul.htabs li:first a').addClass('current'); $(id + 'ul.htabs li a').click(function(){ $(id + 'ul.htabs li a').removeClass('current'); $(this).addClass('current'); var currentTab = $(this).attr('href'); $(id + 'div.tab').hide(); $(currentTab).show(); return false; }); }); Obviously I'm doing something wrong here but as a jQuery newcomer I'm stumped!

    Read the article

  • jquery: set variable based on one class from an element that has more than one class

    - by John
    Hi I'm trying to make a table who's columns and rows highlight on hover (I realise there are jquery plugins out there that will do this, but I'm trying to learn, so thought I'd have a stab at doing it for myself.) Here's what I've got so far: $('th:not(.features), td:not(.features)').hover(highlight); function highlight(){ $('th.highlightCol, td.highlightCol').removeClass('highlightCol'); var col = $(this).attr('class'); $('.' + col).addClass('highlightCol'); }; $('tr').hover(highlightRowOn, highlightRowOff); function highlightRowOn(){ $(this).children('td:not(.highlightCol)').addClass('highlightRow'); }; function highlightRowOff(){ $(this).children('td:not(.highlightCol)').removeClass('highlightRow'); }; This works fine apart from one problem: Each 'td' has a class specific to it's column (package1, package2, package3, package4). It is this that gets passed to the variable (col) to add the class 'highlightCol' to a column when one of its 'td's are hovered on. However, If you move the cursor to a new column along a highlighted row, the 'td' you land on has two classes (highlightedRow and package* ). These both get passed to the variable and as a result the new column does not receive the correct class to highlight. Is there a way for me to target just the 'package* ' class and pass that to the variable while ignoring the 'highlightedRow' class? I hope that's not too jumbled for someone to make sense of and many thanks for any help offered.

    Read the article

  • how to reapply knockout binding

    - by MikeW
    Currently I have a knockout binding that stripes rows in a list which works fine ko.bindingHandlers.stripe = { update: function (element, valueAccessor, allBindingsAccessor) { var value = ko.utils.unwrapObservable(valueAccessor()); //creates the dependency var allBindings = allBindingsAccessor(); var even = allBindings.evenClass; var odd = allBindings.oddClass; //update odd rows $(element).children(":nth-child(odd)").addClass(odd).removeClass(even); //update even rows $(element).children(":nth-child(even)").addClass(even).removeClass(odd); ; } } Triggered from <button data-bind="click: addWidget" style="display:none">Add Item</button> The problem I have is when reloading data from the server , I call addWidget() manually in the view model the stripe binding handler is not applied - all rows appear as same color, if I click the html button then the binding happens and stripes appear var ViewModel = function() { self.addWidget(); }); Is it possible to reapply this custom binding manually in js? Thanks Edit: The stripe binding gets applied like so <div data-bind="foreach: widgets, stripe: widgets, evenClass: 'light', oddClass: 'dark'">

    Read the article

  • Phonegap / jquery mobile slide transition not workign properly on first call

    - by Alexander Casassovici
    I have an awkward visual glitch. I want nice transition when changing pages on the app. Unfortunately first time i change to another page, Instead of sliding current pagg out and new page in , current page is immediately replaces by the new page, then slides out... and when it's out of view it's the new page is shown... the second time around it works like a charm though !!! This is running on iphone with jquery mobile + phonegap I made a video to make the issue clear: http://www.youtube.com/watch?v=Ybvzh_wTnSE <body style="background-color: #000;"> <div id="container" style="display:none;"> <div id="side-menu" style="display:none;"> <div id="header_top"></div> <a href="#dives" onclick="showdives();"><div id="header_dives" class="selected"></div></a> <div id="header_spacer1"></div> <a href="#explore" onclick="showexplore();"><div id="header_explore"></div></a> <div id="header_spacer2"></div> <a href="#search" onclick="showsearch();"><div id="header_search"></div></a> <div id="header_spacer3"></div> <a href="#settings" onclick="showsettings();"><div id="header_settings"></div></a> <div id="header_bottom"></div> </div> <div id="slide_mask"> <!-- START of LOGIN page --> <div data-role="page" id="login"> <div id="home_frame"> <div id="home_logo"></div> <div id="home_fblogin" onclick="login()"></div> <div class="home_login"> <p>Email: <input type="text" name="user[email]" size="30"/></p> <p>Password: <input type="password" name="user[password]" size="30"/></p> <button onclick="show_page_home();">LOGIN</button> </div> </div> </div> <!-- END of LOGIN page --> <!-- START of LOGIN page --> <div data-role="page" id="dives" class="right_pane"> <p>My dives !</p> </div><!-- /content --> <div data-role="page" id="explore" class="hidden right_pane"> <p>My explore !</p> </div><!-- /content --> <div data-role="page" id="search" class="hidden right_pane"> <p>My search !</p> </div><!-- /content --> <div data-role="page" id="settings" class="hidden right_pane"> <p>My settings !</p> <button onclick="logout_db();">logout</button> </div><!-- /content --> <!-- END of LOGIN page --> </div> </div> <div id="log"></div> <div id="data"></div> </body> And the relevant CSS: body {margin: 0; font: 18px Helvetica; text-align: center; background-color: #000; background: url(../img/bg_big.png) repeat; -webkit-user-select: none; /* prevent copy paste for all elements */ } #container { width:320px; height:460px; overflow: hidden;} input{ -webkit-user-select: text; /* enable copy paste for elements with this class */} a {-webkit-user-select: none; /* prevent copy paste for all elements */} span {-webkit-user-select: none; /* prevent copy paste for all elements */} #side-menu {z-index: 1000 !important; position: fixed; height: 460px; width: 56.5px; background: url(../img/bg_big.png) no-repeat; display: inline-block; overflow: hidden; top: 0px; left: 0px; } #header_top {background: url(../img/header/header_top.png) no-repeat; background-size: 56.5px 48.96px; width: 56.5px; height: 48.96px; display: block;} #header_dives {background: url(../img/header/dives.png) no-repeat; background-size: 56.5px 51.75px; width: 56.5px; height: 51.75px; display: block;} #header_dives.selected{background: url(../img/header/dives_selected.png) no-repeat;} #header_spacer1{background: url(../img/header/header_space1.png) no-repeat; background-size: 56.5px 13.9px; width: 56.5px; height: 13.9px; display: block;} #header_explore{background: url(../img/header/explore.png) no-repeat; background-size: 56.5px 51.75px; width: 56.5px; height: 51.75px; display: block;} #header_explore.selected{background: url(../img/header/explore_selected.png) no-repeat;} #header_spacer2{background: url(../img/header/header_space2.png) no-repeat; background-size: 56.5px 15.33px; width: 56.5px; height: 15.33px; display: block;} #header_search{background: url(../img/header/search.png) no-repeat; background-size: 56.5px 51.75px; width: 56.5px; height: 51.75px; display: block;} #header_search.selected{background: url(../img/header/search_selected.png) no-repeat;} #header_spacer3{background: url(../img/header/header_space3.png) no-repeat; background-size: 56.5px 17.73px; width: 56.5px; height: 17.73px; display: block;} #header_settings{background: url(../img/header/settings.png) no-repeat; background-size: 56.5px 51.75px; width: 56.5px; height: 51.75px; display: block;} #header_settings.selected{background: url(../img/header/settings_selected.png) no-repeat;} #header_bottom{background: url(../img/header/header_bottom.png) no-repeat; background-size: 56.5px 160px; width: 56.5px; height: 160px; display: block;} .hidden {display: none;} .right_pane{width: 263.5px !important; background: url(../img/right_bg.png) no-repeat; background-size:263.5px 460px; width: 263.5px; height: 460px; left: 56.5px !important;} #slide_mask{ display: inline-block; overflow: hidden; padding-left: 56.5px; width: 263.5px; height: 460px; top: 0;} and the bit of JS: /////////////////////////////////// //MENU MECHANICS /////////////////////////////////// function showdives(){ $("#side-menu .selected").removeClass("selected"); $("#header_dives").addClass("selected"); } function showexplore(){ $("#side-menu .selected").removeClass("selected"); $("#header_explore").addClass("selected"); } function showsearch(){ $("#side-menu .selected").removeClass("selected"); $("#header_search").addClass("selected"); } function showsettings(){ $("#side-menu .selected").removeClass("selected"); $("#header_settings").addClass("selected"); } the onclick only add/remove the "selected" class to the menu items so... any hint ? been trying eveything for hours and still can't get it neat .. :(

    Read the article

  • HTML5 Drag n Drop File Upload

    - by Paris
    I'm running a website, where I'd like yo upload files with Drag 'n Drop, using HTML5's File Api and FileReader API. I have successfully managed to create a new FileReader, but I don't know how to upload the file. My code (javascript) is the following : holder = document.getElementById('uploader'); holder.ondragover = function () { $("#uploader").addClass('dragover'); return false; }; holder.ondragend = function () { $("#uploader").removeClass('dragover'); return false; }; holder.ondrop = function (e) { $("#uploader").removeClass('dragover'); e.preventDefault(); var file = e.dataTransfer.files[0], reader = new FileReader(); reader.onload = function (event) { //I shoud upload the file now... }; reader.readAsDataURL(file); return false; }; I also have a form (id : upload-form) and an input file field (id : upload-input). Do you have any ideas? P.S. I use jQuery, that's why there is $("#uploader") and others..

    Read the article

  • Jquery cant get facebox working inside ajax call

    - by John
    From my main page I call an ajax file via jquery, in that ajax file is some additional jquery code. Original link looks like this: <a href="/page1.php" class="guest-action notify-function"><img src="/icon1.png"></a> Then the code: $(document).ready(function(){ $('a[rel*=facebox]').facebox(); $('.guest-action').click( function() { $.get( $(this).attr('href'), function(responseText) { $.jGrowl(responseText); }); return false; }); $('.notify-function').click( function() { $(this).find('img').attr('src','/icon2.png'); $(this).attr('href','/page2.php'); $(this).removeClass('guest-action').removeClass('notify-function').attr('rel','facebox'); }); }); So basically after notify-function is clicked I am changing the icon and the url of the link, I then am removing the classes so that the click wont be ran again and add rel="facebox" to the link so that the facebox window will pop up if they try to click the new icon2.png that shows up. The problem is after I click the initial icon everything works just fine except when I try to click the new icon2.png it still executes the jgrowl code from the guest-action. But when I view the source it shows this: <a href="/page2.php" rel="facebox" class=""><img src="/icon2.png"></a> So it seemed that should work right? What am I doing wrong? I tried adding the facebox code to the main page that is calling the ajax file as well and still same issue.

    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

  • Javascript tr click event with newly created rows

    - by yalechen
    I am very new to web development. I am currently using tablesorter jquery plugin to create a dynamic table, where the user can add and delete rows. I am having trouble with changing the background color of newly created rows upon clicking. It works fine with rows that are hard coded in html. Here is the relevant code: $(document).ready( function() { $('table.tablesorter td').click( function (event) { $(this).parent('tr').toggleClass('rowclick'); $(this).parent('tr').siblings().removeClass('rowclick'); }); } ) rowclick is a css class here: table.tablesorter tbody tr.rowclick td { background-color: #8dbdd8; } I have tried adding the following to my javascript function that adds a new row: var createClickHandler = function(newrow) { return function(event) { //alert(newrow.cells[0].childNodes[0].data); newrow.toggleClass('rowclick'); newrow.siblings().removeClass('rowclick'); }; } row.onclick = createClickHandler(row); The alert correctly displays the text in the first column of the row when I click the new row. However, my new rows do not respond to the css class. Anyone have any ideas? Thanks in advance.

    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

  • JQuery validate e-mail address regex

    - by RussP
    Hi folks, not too sure about how to do this. I need/want to validate email addresses by regex using something like this: [a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum) Not I need to run this in a JQ function like this: Where does the validation go and wht is the expression? - please $j("#fld_emailaddress").live('change',function() { var emailaddress = $j("#fld_emailaddress").val(); // validation here? if(emailaddress){} // end validation $j.ajax({ type: "POST", url: "../ff-admin/ff-register/ff-user-check.php", data: "fld_emailaddress="+ emailaddress, success: function(msg) { if(msg == 'OK') { $j("#fld_username").attr('disabled',false); $j("#fld_password").attr('disabled',false); $j("#cmd_register_submit").attr('disabled',false); $j("#fld_emailaddress").removeClass('object_error'); // if necessary $j("#fld_emailaddress").addClass("object_ok"); $j('#email_ac').html('&nbsp;<img src="img/cool.png" align="absmiddle"> <font color="Green"> Your email <strong>'+ emailaddress+'</strong> is OK.</font> '); } else { $j("#fld_username").attr('disabled',true); $j("#fld_password").attr('disabled',true); $j("#cmd_register_submit").attr('disabled',true); $j("#fld_emailaddress").removeClass('object_ok'); // if necessary $j("#fld_emailaddress").addClass("object_error"); $j('#email_ac').html(msg); } } }); });

    Read the article

  • Is it possible to guarantee a unique id for multiple items using the same id variable at a point in

    - by Scarface
    First of all, do not be overwhelmed by the long code, I just put it for reference...I have a function that preg_replaces content and puts it in a jquery dialog box with a matching open-link. For example, if there is a paragraph with two matches, they will be put inside two divs, and a jquery dialog function will be echoed twice; one for each div. While this works for one match, if there are multiple matches, it does not. I am not sure how to distribute unique ids at a point in time for each of the divs and matching dialog open-scripts. Keep in mind, I removed the preg replace function since it kind of complicates the problem. If anyone has any ideas, they will be greatly appreciated. <?php $id=uniqid(); $id2=uniqid(); echo "<div id=\"$id2\"> </div>"; ?> $.ui.dialog.defaults.bgiframe = true; $(function() { $("<?php echo"#$id2"; ?>").dialog({hide: 'clip', modal: true ,width: 600,height: 350,position: 'center', show: 'clip',stack: true,title: 'title', minHeight: 25, minWidth: 100, autoOpen: false}); $('<?php echo"#$id"; ?>').click(function() { $('<?php echo"#$id2"; ?>').dialog('open'); }) .hover( function(){ $(this).addClass("ui-state-hover"); }, function(){ $(this).removeClass("ui-state-hover"); } ).mousedown(function(){ $(this).addClass("ui-state-active"); }) .mouseup(function(){ $(this).removeClass("ui-state-active"); }); });

    Read the article

  • Removing empty space with jQuery after deleting Selectable item

    - by Tx3
    I have two ordered lists and user can move items between them. I am using jQuery UI's Selectable for both of them. Problem is that when I move item from the middle of the list it leaves an empty space behind. How can I make list shrink according to the how many items is actually in the list? HTML <ol id="allUnits"> <li class="ui-state-default">Item 1</li> <li class="ui-state-default">Item 2</li> <li class="ui-state-default">Item 3</li> <li class="ui-state-default">Item 4</li> <li class="ui-state-default">Item 5</li> </ol> <input id="arrowRight" type="image" alt="Move item to right" src="<%= Url.Content("~/Content/Images/arrowRight.png")%>" /> <input id="arrowLeft" type="image" alt="Move item to left" src="<%= Url.Content("~/Content/Images/arrowLeft.png")%>" /> <ol id="productUnits"> <li class="ui-state-default">Item 1</li> <li class="ui-state-default">Item 2</li> <li class="ui-state-default">Item 3</li> <li class="ui-state-default">Item 4</li> <li class="ui-state-default">Item 5</li> </ol> jQuery $().ready(function () { $("#allUnits").selectable(); $("#productUnits").selectable(); $('#arrowRight').click(function () { return !$('#allUnits .ui-selected').remove().appendTo('#productUnits').removeClass(".ui-selected"); }); $('#arrowLeft').click(function () { return !$('#productUnits .ui-selected').remove().appendTo('#allUnits').removeClass(".ui-selected"); }); });

    Read the article

  • How to use JQuery Validate to create a popup with all form error when the submit button is clicked?

    - by Larry
    I am using the JQuery Validation plugin for client side form validation. In addition to the colorful styling on invalid form fields, my client requires that a popup message be shown. I only want to show this message when the submit button is click because it would drive the user crazy otherwise. I tried the following code, but errorList is always empty. Anyone know the correct way to do something similar. function popupFormErrors(formId) { var validator = $(formId).validate(); var message = ''; for (var i = 0; i < validator.errorList.length - 1; i++) { message += validator.errorList[i].message + '\n'; } if (message.length > 0) { alert(message); } } $('#btn-form-submit').click(function(){ $('#form-register').submit(); popupFormErrors('#btn-form-submit'); return false; }); $('#form-register').validate({ errorPlacement: function(error, element) {/* no room on page */}, highlight: function(element) { $(element).addClass('invalid-input'); }, unhighlight: function(element) { $(element).removeClass('invalid-input'); }, ... }); Update From the info in the accepted answer I came up with this. var submitClicked = false; $('#btn-form-submit').click(function() { submitClicked = true; $('#form-register').submit(); return false; }); $('#form-register').validate({ errorPlacement: function(error, element) {/* no room on page */}, highlight: function(element) { $(element).addClass('invalid-input'); }, unhighlight: function(element) { $(element).removeClass('invalid-input'); }, showErrors: function(errorsObj) { this.defaultShowErrors(); if (submitClicked) { submitClicked = false; ... create popup from errorsObj... } } ... });

    Read the article

  • Advise guidance on how to form this jQuery script for show/hide fade element

    - by Rick
    Hey guys.. I basically have several links on the left side of the screen and on the right is a preview window. Below the preview window is another box for the affiliate link code. So what I am trying to do is create an affiliate page where you choose the banner size on the left by clicking on the link and on the right you see it dynamically change to the banner size and the code changes accordingly as well. So far I have the following code and it works but it seems very very cumbersome and bloated. Can you see if I can trim this down? jQuery(".banner-style li").click(function() { jQuery(".banner-style li").removeClass("selected"); jQuery(this).addClass("selected"); var $banner = jQuery(this).attr("class"); $banner = $banner.replace(" selected",""); jQuery(".preview img").fadeOut('fast',function() { jQuery(".preview img").attr("src", "http://localhost/site/banners/"+$banner+".jpg") .fadeIn('slow'); }); jQuery(".code p").removeClass('hide').hide(); jQuery(".code p."+$banner).show(); }); Also to note the funny thing is in FF, when you click for the first to on any link, the original image on the right fades out and in real quick and then it loads the "clicked" image. This does not happen in other browsers...

    Read the article

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