Search Results

Search found 178 results on 8 pages for 'mouseout'.

Page 1/8 | 1 2 3 4 5 6 7 8  | Next Page >

  • jQuery animate mouseover/mouseout keep drop menu visible

    - by Ce.
    I'm trying to make a basic drop down menu with animate and am running into the issue where I can't seem to figure out how to keep the dropdown part open until the mouse leaves. Is there an easy way to tell this to stay open? I know what I have is completely wrong regarding the .clickme mouseout function since it will unload the menu accordingly. If anyone can help in this specific instance, I would be super grateful. PREVIEW HERE http://cu3ed.com/ddmenu/ or below: $(document).ready(function() { $('.clickme').mouseover(function() { $('#slidebox').animate({ top: '+=160' }, 200, 'easeOutQuad'); }); $('.clickme').mouseout(function(){ $('#slidebox').animate({ top: '-=160' }, 200, 'easeOutQuad') }); }); I would like to keep this as simple and clean as possible. I know the CSS is all crazy but it's totally preliminary. THANKS!!!

    Read the article

  • jquery mouseout problem

    - by From.ME.to.YOU
    hello my html <div id="parent"> <div id="child">cx</div> </div> when i use jquery $('#parent').mouseout(function(){ //something here }); i wonder why when my mouse enter the child div the function fires. i'm still inside parent div. i want that mouseout function to fire only when i leave the parent div not when i'm on any child div http://jsbin.com/esiju/ << example Cheers

    Read the article

  • jQuery and executing code until mouseout is called

    - by Tomaszewski
    Good day all, I am tasked with building a slider for our site. Here is my goal: <div id="abc"> <div id="slider">...</div> </div> I need to move "slider" left 30px at a time when a button is hovered over, and right 30px when another button is hovered over. My problem is that there doesn't seem to be a reliable method for telling the code that the mouse hasn't left the are in question, unless there is something I did not think about or read yet. In other words, when the mouse is OVER the a button, the code to move "slider" left is executed until the mouseout is called. I'm not really sure how to do this. The only way I can think of is to look at the offsetTop and offsetLeft and offsetTop DOM properties and compare them to the mouse position, than run checks to see if the mouse is within the bounds of the box, and if not than it will stop the execution of code. Is there a better way to do this?

    Read the article

  • Why this mouseout will be called when i move out of li instead of ul?

    - by terry
    i want to call mouseout of ul tag, but it looks it will call mouseout as well when i move between two li tags, what's wrong? how can i make it work when i move mouse out of the ul? thanks a lot! $(document).ready(function(){ $("#info").live("mouseout", function(){ console.log('mouseout'); }); }); HTML <div id="latest"> <ul id="info"> <li>test1</li> <li>test2</li> </ul> </div>

    Read the article

  • Children inside <a href> trigger mouseout. How to prevent that?

    - by stagas
    I have this: <a href="javascript:void(0);"> <div> <span>some content</span> <span>some content</span> </div> </a> The problem is hovering the mouse over from one <span> to another triggers an instant mouseout and mouseover again even though they have no padding or margin between them. Even on the browser's status bar the link flickers for an instant. How can this be prevented?

    Read the article

  • Javascript: Multiple mouseout events triggered

    - by Channel72
    I'm aware of the different event models in Javascript (the WC3 model versus the Microsoft model), as well as the difference between bubbling and capturing. However, after a few hours reading various articles about this issue, I'm still unsure how to properly code the following seemingly simple behavior: If I have an outer div and an inner div element, I want a single mouse-out event to be triggered when the mouse leaves the outer-div. When the mouse crosses from the inner-div to the outer-div, nothing should happen, and when the mouse crosses from the outer-div to the inner-div nothing should happen. The event should only fire if the mouse moves from the outer-div to the surrounding page. <div id="outer" style = "width:20em; height:20em; border:1px solid #F00" align = "center" onmouseout="alert('mouseout event!')" > <div id="inner" style = "width:18em; height:18em; border:1px solid #000"></div> </div> Now, if I place the "mouseout" event on the outer-div, two mouse-out events are fired when the mouse moves from the inner-div to the surrounding page, because the event fires once when the mouse moves from inner to outer, and then again when it moves from outer to the surrounding page. I know I can cancel the event using ev.stopPropagation(), so I tried registering an event handler with the inner-div to cancel the event propagation. However, this won't prevent the event from firing when the mouse moves from the outer-div to the inner-div. So, unless I'm overlooking something, it seems to me this behavior can't be accomplished without complex mouse-tracking functions. In the future, I plan to reimplement a lot of this code using a more advanced framework, like JQuery, but for now, I'm wondering if there is a simple way to implement the above behavior in regular Javascript.

    Read the article

  • jquery mouseover/mouseout

    - by Hulk
    In the following code once the mouse out is done the mouse over again does not work ,what is the work around for this <!DOCTYPE html> <html> <head> <style> /* div { background:#def3ca; margin:3px; width:80px; display:none; float:left; text-align:center; }*/ </style> <script src="http://code.jquery.com/jquery-latest.min.js"></script> </head> <body> <div id="playControls" style="position:absolute; bottom:0px; left:0px; right:0px;color:blue;"> Mouse over me </div> <script> $(document).ready(function() { $("#playControls").mouseover(function () { alert('here'); $("div:eq(0)").show("fast", function () { /* use callee so don't have to name the function */ $(this).next("div").show("fast", arguments.callee); }); }); $("#playControls").mouseout(function () { alert('here'); $("div").hide(2000); }); }); </script> </body> </html>

    Read the article

  • jQuery change CSS background position and mouseover/mouseout

    - by steelfrog
    I have a menu composed of a single image (e.g., sprites). In order to display the hover image, I simply move the background image down. I'd like this effect to be controlled by jQuery and animated. This is a sample menu item. <ul> <li id="home"><a href="#"></a></li> </ul> This is what I'm toying with. I'm very new to jQuery and am having problems getting the proper selector going. $(document).ready(function(){ $('#home a'); // Set the 'normal' state background position .css( {backgroundPosition: "0 0"} ) // On mouse over, move the background .mouseover(function(){ $(this).stop().animate({backgroundPosition:"(0 -54px)"}, {duration:500}) }) // On mouse out, move the background back .mouseout(function(){ $(this).stop().animate({backgroundPosition:"(0 0)"}, {duration:500}) }) }); Could you point out what I'm doing wrong? I know the selector is probably incorrect but I'm having a hard time figuring out how to manipulate the anchor.

    Read the article

  • Calling javascript function on the Mousehoever and mouseout using jQuery

    - by Wazdesign
    I want to call the javascript function using mousehover jQuery event. Here is the one function. // On mouse hover function function ShowHighlighter(d, highlight_elid) { //alert ("ShowHighlighter\n"+d); if (d == "addHighlight") { var txt = getSelText(); if (txt.length < 1) { return; } ShowContent(d); } else if (d == "deleteHighlight") { var elid = "#"+d; jQuery(elid).stop(); ShowContent(d); delete_highlight_id = "#"+highlight_elid; } } // on Mouse out function function HideContent(d) { if(d.length < 1) { return; } document.getElementById(d).style.display = "none"; } I am trying to use this function ... but it not seems to be working. jQuery('a[href="HIGHLIGHT_CREATELINK"]').mouseover(ShowHighlighter("deleteHighlight","highlight"+ randomCount + ");) ; jQuery('a[href="HIGHLIGHT_CREATELINK"]').mouseout('javascript:HideContentFade(\"deleteHighlight\");') please help me out in this. thanks.

    Read the article

  • Cursor image to the center on mouseout

    - by Milla
    Hi all! I'm a real noobie with flash and I was wondering if somebody could help me with this one. I have this actionsript 3 code, where the cursor image "ball_mc" follows the mouse's position with a slight delay: stage.addEventListener(Event.ENTER_FRAME,followBall); function followBall(event:Event):void { var dx:int = ball_mc.x - mouseX; var dy:int = ball_mc.y - mouseY; ball_mc.x -= dx / 5; ball_mc.y -= dy /5; } 1) How can I get the cursor image automatically return to the center of the stage on mouseout? As of now, it stays at the position where the mouse leaves the stage. 2) How can I reverse the movement of the mouse? So that when I, for example, move mouse to the right, the cursor image would move to the left? And when moving the mouse up, the image would go down. The stage is 800 x 250 pixels, in case that makes any difference.

    Read the article

  • jquery stop image rotation on mouseover, start on mouseout / hover

    - by Matt Nathanson
    I have built a jQuery rotator to rotate through 3 divs and loop them. I would like to add the functionality on mouse over to "freeze" the current div and then start again on mouse out. I've thought about setting a variable to false at the start of the function and setting it true when it's on it's current frame but I've got my self a bit confused. I've also tried to use the hover function but when using the in and out handlers, I'm confused as to how to stop, restart the animation. function ImageRotate() { var CurrentFeature = "#container" + featureNumber; $(CurrentFeature).stop(false, true).delay(4500).animate({'top' : '330px'}, 3000); var featureNumber2 = featureNumber+1; if ( featureNumber == numberOfFeatures) {featureNumber2 = 1} var NewFeature = "#container" + featureNumber2; $(NewFeature).stop(false, true).delay(4500).animate({'top' : '0px'}, 3000); var featureNumber3 = featureNumber-1; if ( featureNumber == 1) {featureNumber3 = numberOfFeatures}; var OldFeature = "#container" + featureNumber3; $(OldFeature).stop(false, true).delay(4500).css('top' , '-330px'); setTimeout('if (featureNumber == numberOfFeatures){featureNumber = 1} else {featureNumber++}; ImageRotate2()', 7500)}; Any help would be greatly appreciated!! Thanks, Matt

    Read the article

  • FLEX: is PopupManager working with mouseover / mouseout events ?

    - by Patrick
    hi, I want to make work PopupManager as a Tooltip. So I want to create a popup everytime I move the mouse over my component and make it disappear when I move the mouse out. Moreover, I have many components in my canvas, so I need it not to be too expensive. Also, when I move the mouse out from the component, but over the pop-up, it should not disappear, because I want to click on the buttons inside it. I need something similar to gmail chat popups. Is it doable with PopupManager ? thanks

    Read the article

  • handling mouseover/mouseout events for dijit.TitlePane's titleNode

    - by Shailesh Kumar
    I have a lot of dijit.TitlePanes stacked up one after another. I wish to handle the onmouseover and onmouseout events for the tile part of the TitlePane. What is the correct way of doing this? Will something like : dojo.connect(titlePane.titleNode, 'onmouseover', function f() {}); work, where titlePane is a reference to some dijit.TitlePane object? Is there some declarative way of setting up such an event handler using "dojo/mehtod"?

    Read the article

  • dojo connect mouseover and mouseout

    - by peirix
    When setting up dojo connections to onmouseover and onmouseout, and then adding content on mouseover, dojo fires the onmouseout event at once, since there is new content. Example: dojo.query(".star").parent().connect("onmouseover", function() { dojo.query("span", this).addContent("<img src='star-hover.jpg'>"); }).connect("onmouseout", function() { dojo.destroy(dojo.query("img", this)[0]); }); The parent() is a <td>, and the .star is a span. I want to add the hover image whenever the user hovers the table cell. It works as long as the cursor doesn't hover the image, because that will result in some serious blinking. Is this deliberate? And is there a way around it?

    Read the article

  • jQuery: Show and hide child div when hovering

    - by Björn
    Hi there, I've got a set of items. Each item has two images and some text. For the images I've created a parent div which has an overflow:hidden CSS value. I want to achieve an mouseover effect. As soon as you hover over the images I want to hide the current div and show the second div. Here's a small snippet: <div class="product-images"> <div class="product-image-1"><img src="image1.gif>" /></div> <div class="product-image-2"><img src="images2.gif" /></div> </div> I've created a small jQuery snippet: jQuery(document).ready(function() { jQuery('.product-images').mouseover(function() { jQuery('.product-image-1').hide(); }).mouseout(function() { jQuery('.product-image-1').show(); }); }); Now the problem is that not only the currently hovered child is hidden. Instead all other existing childs are hidden as well. I need something like "this" or "current" but I don't know which jQuery function is the right one. Any idea? Thanks, BJ

    Read the article

  • jquery hover issue

    - by jay
    hi, i have mouseover issues sometimes when i move my mouse fast over links it loops for quite a while, is there a way to only loop if mouse is stil over and stop if the mouse is not. $('ul.display li').hover(function() { $('ul.display li').find('#details').hide(); // hides all deatils div before showing $('#light').delay('800').fadeIn("fast"); // shows div that fades out all other content. if($.cookie("switch_thumb") =="thumb_view" || $.cookie("switch_thumb") =="null"){//checks for cookie set for display type $(this).find('#details').delay('900').animate({width:'toggle'}); // grow width }else{ $(this).find('#details').delay('900').animate({height:'toggle'}); // grow height } }, function() { $('#light').fadeOut("fast"); // dim the light to show all content $('ul.display li').find('#details').hide(); //hide all details return false; // supposed to stop looping. });

    Read the article

  • Difference in clientX and clientY when going out of the browser on ie/ff

    - by Py
    I just ran into a little problem with clientX and clientY. I put a little event to detect if the mouse goes out of the window and to know where it exits. And there come the trouble, it works fine with firefox, but only sends -1 as an answer in IE. Does someone know if there is a way to solve easily that problem and that without using a framework? A little bit of code to reproduce that: <html> <head> <script type="text/javascript"> document.onmouseout=function(e){ if (!e) var e = window.event; var relTarg = e.relatedTarget || e.toElement; if (!relTarg){ document.getElementById('result1').innerHTML="e.clientY:"+e.clientY+" e.clientX:"+e.clientX; } }; </script> </head> <body> <div id="result1">Not Yet</div> </body> </html> the results if I exit through the left of the window are: e.clientY:302 e.clientX:-130 on firefox e.clientY:-1 e.clientX:-1 on ie. Thanks in advance.

    Read the article

  • Passing variable in jQuery through bind doesn't seem to work...

    - by dallen
    Here's my code that does work: function mouseOver() { $(".beaver").fadeIn(100); } function mouseOut() { $(".beaver").fadeOut(100); } $("#group_beaver").bind('mouseenter', mouseOver).bind('mouseleave', mouseOut); But why doesn't this work? function mouseOver(variable) { $(variable).fadeIn(100); } function mouseOut(variable) { $(variable).fadeOut(100); } $("#group_beaver").bind('mouseenter', mouseOver('.beaver')).bind('mouseleave', mouseOut('.beaver'));

    Read the article

  • Mootools - how to destroy a class instance

    - by Rob
    What I'm trying to do is create a class that I can quickly attach to links, that will fetch and display a thumbnail preview of the document being linked to. Now, I am focusing on ease of use and portability here, I want to simply add a mouseover event to links like this: <a href="some-document.pdf" onmouseover="new TestClass(this)">Testing</a> I realize there are other ways I can go about this that would solve my issue here, and I may end up having to do that, but right now my goal is to implement this as above. I don't want to manually add a mouseout event to each link, and I don't want code anywhere other than within the class (and the mouseover event creating the class instance). The code: TestClass = new Class({ initialize: function(anchor) { this.anchor = $(anchor); if(!this.anchor) return; if(!window.zzz) window.zzz = 0; this.id = ++window.zzz; this.anchor.addEvent('mouseout', function() { // i need to get a reference to this function this.hide(); }.bind(this)); this.show(); }, show: function() { // TODO: cool web 2.0 stuff here! }, hide: function() { alert(this.id); //this.removeEvent('mouseout', ?); // need reference to the function to remove /*** this works, but what if there are unrelated mouseout events? and the class instance still exists! ***/ //this.anchor.removeEvents('mouseout'); //delete(this); // does not work ! //this = null; // invalid assignment! //this = undefined; // invalid assignment! } }); What currently happens with the above code: 1st time out: alerts 1 2nd time out: alerts 1, 2 3rd time out: alerts 1, 2, 3 etc Desired behavior: 1st time out: alerts 1 2nd time out: alerts 2 3rd time out: alerts 3 etc The problem is, each time I mouse over the link, I'm creating a new class instance and appending a new mouseout event for that instance. The class instance also remains in memory indefinitely. On mouseout I need to remove the mouseout event and destroy the class instance, so on subsequent mouseovers we are starting fresh.

    Read the article

  • HTML + javascript mouse over, mouseout, onclick not working in firefox.

    - by help_inmssql
    Hello Everyone, My question is to get onMouseover,onMouseout,onMousedown,onClick on a table row. For which i am calling javascript userdefined functions. onMouseover --- Background color should change. onMouseout --- Reset to original color onClick --- First column checkbox/radio button should be set and background color should change onMousedown --- background color should change. My code in html is:- <tr onMouseOver="hover(this)" onMouseOut="hover_out(this)" onMouseDown="get_first_state(this)" onClick="checkit(this)" > and the methods in javascripts are:- var first_state = false; var oldcol = '#ffffff'; var oldcol_cellarray = new Array(); function hover(element) { if (! element) element = this; while (element.tagName != 'TR') { element = element.parentNode; } if (element.style.fontWeight != 'bold') { for (var i = 0; i<element.cells.length; i++) { if (element.cells[i].className != "no_hover") { oldcol_cellarray[i] = element.cells[i].style.backgroundColor; element.cells[i].style.backgroundColor='#e6f6f6'; } } } } // ----------------------------------------------------------------------------------------------- function hover_out(element) { if (! element) element = this; while (element.tagName != 'TR') { element = element.parentNode; } if (element.style.fontWeight != 'bold') { for (var i = 0; i<element.cells.length; i++) { if (element.cells[i].className != "no_hover") { if (typeof oldcol_cellarray != undefined) { element.cells[i].style.backgroundColor=oldcol_cellarray[i]; } else { element.cells[i].style.backgroundColor='#ffffff'; } //var oldcol_cellarray = new Array(); } } } } // ----------------------------------------------------------------------------------------------- function get_first_state(element) { while (element.tagName != 'TR') { element = element.parentNode; } first_state = element.cells[0].firstChild.checked; } // ----------------------------------------------------------------------------------------------- function checkit (element) { while (element.tagName != 'TR') { element = element.parentNode; } if (element.cells[0].firstChild.type == 'radio') { var typ = 0; } else if (element.cells[0].firstChild.type == 'checkbox') { typ = 1; } if (element.cells[0].firstChild.checked == true && typ == 1) { if (element.cells[0].firstChild.checked == first_state) { element.cells[0].firstChild.checked = false; } set_rowstyle(element, element.cells[0].firstChild.checked); } else { if (typ == 0 || element.cells[0].firstChild.checked == first_state) { element.cells[0].firstChild.checked = true; } set_rowstyle(element, element.cells[0].firstChild.checked); } if (typ == 0) { var table = element.parentNode; if (table.tagName != "TABLE") { table = table.parentNode; } if (table.tagName == "TABLE") { table=table.tBodies[0].rows; //var table = document.getElementById("js_tb").tBodies[0].rows; for (var i = 1; i< table.length; i++) { if (table[i].cells[0].firstChild.checked == true && table[i] != element) { table[i].cells[0].firstChild.checked = false; } if (table[i].cells[0].firstChild.checked == false) { set_rowstyle(table[i], false); } } } } } function set_rowstyle(r, on) { if (on == true) { for (var i =0; i < r.cells.length; i++) { r.style.fontWeight = 'bold'; r.cells[i].style.backgroundColor = '#f2f2c2'; } } else { for ( i =0; i < r.cells.length; i++) { r.style.fontWeight = 'normal'; r.cells[i].style.backgroundColor = '#ffffff'; } } } It is working as expected in IE. But coming to firefox i am surprised on seeing the output after so much of coding. In Firefox:-- onMouseOver is working as expected. color change of that particular row. onClick -- Setting the background color permenantly..eventhough i do onmouseover on different rows. the clicked row color is not reset to white. -- not as expected onclick on 2 rows..the background of both the rows is set...not as expected i.e if i click on all the rows..background color of everything is changed... Eventhough i click on the row. First column i.e radio button or checkbox is not set.. Please help me to solve this issue in firefox. Do let me know where my code needs to be changed... Thanks in advance!!

    Read the article

  • How can I return a link to an active state after mouseout?

    - by Craig
    var menuEnter = { 'color': hoverColor}; var menuLeave = { 'color': 'C0C0C0'}; new ('div#menu a.level1 span.bg', menuEnter, menuLeave, { transition: Fx.Transitions.linear, duration: 200 }, { transition: Fx.Transitions.sineIn, duration: 500 }); I would like the active menu color to not be affected by the mouseleave var. Thank you.

    Read the article

  • HTML + javascript mouse over, mouseout, onclick not working in firefox.

    - by lucky
    Hello Everyone, My question is to get onMouseover,onMouseout,onMousedown,onClick on a table row. For which i am calling javascript userdefined functions. onMouseover --- Background color should change. onMouseout --- Reset to original color onClick --- First column checkbox/radio button should be set and background color should change onMousedown --- background color should change. My code in html is:- <tr onMouseOver="hover(this)" onMouseOut="hover_out(this)" onMouseDown="get_first_state(this)" onClick="checkit(this)" > and the methods in javascripts are:- var first_state = false; var oldcol = '#ffffff'; var oldcol_cellarray = new Array(); function hover(element) { if (! element) element = this; while (element.tagName != 'TR') { element = element.parentNode; } if (element.style.fontWeight != 'bold') { for (var i = 0; i<element.cells.length; i++) { if (element.cells[i].className != "no_hover") { oldcol_cellarray[i] = element.cells[i].style.backgroundColor; element.cells[i].style.backgroundColor='#e6f6f6'; } } } } // ----------------------------------------------------------------------------------------------- function hover_out(element) { if (! element) element = this; while (element.tagName != 'TR') { element = element.parentNode; } if (element.style.fontWeight != 'bold') { for (var i = 0; i<element.cells.length; i++) { if (element.cells[i].className != "no_hover") { if (typeof oldcol_cellarray != undefined) { element.cells[i].style.backgroundColor=oldcol_cellarray[i]; } else { element.cells[i].style.backgroundColor='#ffffff'; } //var oldcol_cellarray = new Array(); } } } } // ----------------------------------------------------------------------------------------------- function get_first_state(element) { while (element.tagName != 'TR') { element = element.parentNode; } first_state = element.cells[0].firstChild.checked; } // ----------------------------------------------------------------------------------------------- function checkit (element) { while (element.tagName != 'TR') { element = element.parentNode; } if (element.cells[0].firstChild.type == 'radio') { var typ = 0; } else if (element.cells[0].firstChild.type == 'checkbox') { typ = 1; } if (element.cells[0].firstChild.checked == true && typ == 1) { if (element.cells[0].firstChild.checked == first_state) { element.cells[0].firstChild.checked = false; } set_rowstyle(element, element.cells[0].firstChild.checked); } else { if (typ == 0 || element.cells[0].firstChild.checked == first_state) { element.cells[0].firstChild.checked = true; } set_rowstyle(element, element.cells[0].firstChild.checked); } if (typ == 0) { var table = element.parentNode; if (table.tagName != "TABLE") { table = table.parentNode; } if (table.tagName == "TABLE") { table=table.tBodies[0].rows; //var table = document.getElementById("js_tb").tBodies[0].rows; for (var i = 1; i< table.length; i++) { if (table[i].cells[0].firstChild.checked == true && table[i] != element) { table[i].cells[0].firstChild.checked = false; } if (table[i].cells[0].firstChild.checked == false) { set_rowstyle(table[i], false); } } } } } function set_rowstyle(r, on) { if (on == true) { for (var i =0; i < r.cells.length; i++) { r.style.fontWeight = 'bold'; r.cells[i].style.backgroundColor = '#f2f2c2'; } } else { for ( i =0; i < r.cells.length; i++) { r.style.fontWeight = 'normal'; r.cells[i].style.backgroundColor = '#ffffff'; } } } It is working as expected in IE. But coming to firefox i am surprised on seeing the output after so much of coding. In Firefox:-- onMouseOver is working as expected. color change of that particular row. onClick -- Setting the background color permenantly..eventhough i do onmouseover on different rows. the clicked previous row color is not reset to white. -- not as expected onclick on 2 rows..the background of both the rows is set..Only the latest row color should be set. other rows that are selected before should be set back..not as expected i.e if i click on all the rows..background color of everything is changed... Eventhough i click on the row. First column i.e radio button or checkbox is not set.. Please help me to solve this issue in firefox. Do let me know where my code needs to be changed... Thanks in advance!!

    Read the article

  • Dismiss Menu when Focus is lost, not on mouseout. jQuery

    - by Stacey
    I have jQuery that drops a menu down when its parent is clicked on, and dismisses it when they hover away from the menu. I am wanting to change the behavior so that it only dismisses if they click somewhere else on the page, or a different menu. Is this possible? jQuery.fn.dropdown = function () { return this.each(function () { $('.ui-dropdown-list > li > a').click(function () { $(this).addClass("ui-dropdown-hover"); }); $("ul.ui-dropdown-list > li > a").click(function () { $(this).parent().find("ul").show(); $(this).parent().hover(function () { }, function () { $(this).parent().find("ul").hide(); $(this).find('> a').removeClass("ui-dropdown-hover"); }); }); }); };

    Read the article

  • Using jQuery Live instead of jQuery Hover function

    - by hajan
    Let’s say we have a case where we need to create mouseover / mouseout functionality for a list which will be dynamically filled with data on client-side. We can use jQuery hover function, which handles the mouseover and mouseout events with two functions. See the following example: <!DOCTYPE html> <html lang="en"> <head id="Head1" runat="server">     <title>jQuery Mouseover / Mouseout Demo</title>     <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.4.4.js"></script>     <style type="text/css">         .hover { color:Red; cursor:pointer;}     </style>     <script type="text/javascript">         $(function () {             $("li").hover(               function () {                   $(this).addClass("hover");               },               function () {                   $(this).removeClass("hover");               });         });     </script> </head> <body>     <form id="form2" runat="server">     <ul>         <li>Data 1</li>         <li>Data 2</li>         <li>Data 3</li>         <li>Data 4</li>         <li>Data 5</li>         <li>Data 6</li>     </ul>     </form> </body> </html> Now, if you have situation where you want to add new data dynamically... Lets say you have a button to add new item in the list. Add the following code right bellow the </ul> tag <input type="text" id="txtItem" /> <input type="button" id="addNewItem" value="Add New Item" /> And add the following button click functionality: //button add new item functionality $("#addNewItem").click(function (event) {     event.preventDefault();     $("<li>" + $("#txtItem").val() + "</li>").appendTo("ul"); }); The mouse over effect won't work for the newly added items. Therefore, we need to use live or delegate function. These both do the same job. The main difference is that for some cases delegate is considered a bit faster, and can be used in chaining. In our case, we can use both. I will use live function. $("li").live("mouseover mouseout",   function (event) {       if (event.type == "mouseover") $(this).addClass("hover");       else $(this).removeClass("hover");   }); The complete code is: <!DOCTYPE html> <html lang="en"> <head id="Head1" runat="server">     <title>jQuery Mouseover / Mouseout Demo</title>     <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.4.4.js"></script>     <style type="text/css">         .hover { color:Red; cursor:pointer;}     </style>     <script type="text/javascript">         $(function () {             $("li").live("mouseover mouseout",               function (event) {                   if (event.type == "mouseover") $(this).addClass("hover");                   else $(this).removeClass("hover");               });             //button add new item functionality             $("#addNewItem").click(function (event) {                 event.preventDefault();                 $("<li>" + $("#txtItem").val() + "</li>").appendTo("ul");             });         });     </script> </head> <body>     <form id="form2" runat="server">     <ul>         <li>Data 1</li>         <li>Data 2</li>         <li>Data 3</li>         <li>Data 4</li>         <li>Data 5</li>         <li>Data 6</li>     </ul>          <input type="text" id="txtItem" />     <input type="button" id="addNewItem" value="Add New Item" />     </form> </body> </html> So, basically when replacing hover with live, you see we use the mouseover and mouseout names for both events. Check the working demo which is available HERE. Hope this was useful blog for you. Hope it’s helpful. HajanReference blog: http://codeasp.net/blogs/hajan/microsoft-net/1260/using-jquery-live-instead-of-jquery-hover-function

    Read the article

  • Javascript Mouseover bubbling from children

    - by Nicky De Maeyer
    Ive got the following html setup: <div id="div1"> <div id="content1">blaat</div> <div id="content1">blaat2</div> </div> it is styled so you can NOT hover div1 without hovering one of the other 2 divs. Now i've got a mouseout on div1. The problem is that my div1.mouseout gets triggered when i move from content1 to content2, because their mouseouts are bubbling. and the event's target, currentTarget or relatedTarget properties are never div1, since it is never hovered directly... I've been searching mad for this, but I can only find articles and solutions for problems who are the reverse of what I need. It seems trivial but I can't get it to work... The mouseout of div1 should ONLY get triggered when the mouse leaves div1. One of the possibilities would be to set some data on mouse enter and mouseleave, but I'm convinced this should work out of the box, since it is just a mouseout... EDIT: bar.mouseleave(function(e) { if ($(e.currentTarget).attr('id') == bar.attr('id')) { bar.css('top', '-'+contentOuterHeight+'px'); $('#floatable-bar #floatable-bar-tabs span').removeClass('active'); } }); changed the mouseout to mouseleave and the code worked...

    Read the article

1 2 3 4 5 6 7 8  | Next Page >