I'm developing an image slider. I'd like to be able to trigger functions when the mouse leaves an area, sort of like
$('#someDiv').mouseout or $('#someDiv').mouseleave
except instead of passing the div to the function I have a dimension I'd like to pass to it.
I have box like so:
--------------- 400 px ------------
______________________
3 | |
0 | |
0 | |
p | |
x |_____________________|
I have calculated the dimensions from the left of the box to 25% of the width of the box to the right (or 100px from the left of the box) and also calculated the height of the box and top offset. I want to be able to say if the mouse leaves those dimensions, run a function.
Can I pass the dimensions and use mouseout or mouseleave? is this possible without using an HTML element?
I am making an image slider for my company and that when you hover over the image, depending on whether the mouse is on the right half or the left half of the image, a tiny overlay appears on that corresponding side of the image with a next image link.
I can't seem to wrap my head around how to detect whether a mouse is on left side or the right side of the image. I looked into offset but that's an element's offset relative to the document. Now I could do it by getting the elements offset and subtracting the offset of the mouse from offset of the container element on hover, but there seems like there has to be a much better, more reliable way.
Any help would be much appreciated!
If it helps, right now (for beta) the image sizes are static, 400px by 300px.
I have two divs that are in the same parent div, only one is shown at once. When I toggle the one that is smaller (height-wise), the position of the scroll bar (and hence the user's current location on the page) remains the same. But when I toggle back to the taller div, the scroll bar launches you back up almost to the top of the page.
Is there a way I can stop this from happening?
In a hopeless effort I tried return false which i knew wouldn't work. I also looked into scrollTop() but that doesn't seem like it will be of any help since it only returns values and does not set any values?
What would be the difference between setting up a click handler using .click() or binding the click handler:
$('.cancelButton').click(function() {
$('.dialog1').dialog('close');
});
VS
$('.cancelButton').bind('click', function(){
$('.dialog1').dialog('close');
});
Obviously they both do the same thing, but is one better (in terms of speed or practice) or does it not matter at all which one you use? I usually use .click() to avoid the extra typing but I want to make sure I'm not missing anything.
From the title, you're probably already thinking the .next() method (not the case).
I have a simple set of 5 images (although the number is dynamic, for now we'll say 5). They are put on the page with only the first image displayed, all others are display:none.
All I want to do is to write a function that when a user clicks the 'next' or 'previous' buttons, the image changes to the very next image in the group. I cannot use .next() because it will grab all siblings and display them, I only want the one directly before or after the current image depending on whether a user clicks next or previous.
Using the nextUntil() method isn't going to work either cause all siblings are the same.
I know that I can put these into an array and then I will have an index in which I can then use math to just increment or decrement the array to the index I want displayed, but this seems unnecessary and too much work for jQuery. I must be missing something? Is there an easy way to just grab the very next sibling element, is there a method of some sort that I somehow missed? If not, how would you handle this problem?
I'm setting up my navigation on my personal site. I have just a basic little layout and a navigation. The navigation is super simple, just plain text links that when they are hovered I set a border-bottom property so I can have a nice thick line below them. However, I can't get a.selected working. When a user hovers, I want a border-bottom property to be displayed but I also want a border-bottom property on the selected link, or the link to the page they are currently on. So if they were on the portfolio page, the portfolio link would have a border-bottom property set, whether they were hovering over it or not. I should be able to use 'a.selected' for this but it's not working and I've tried it a million different ways.
So my question is a simple one. How do I get jQuery to recognize the link of the page I'm currently on? I've seen it done before but for the life of me I can't remember how to do it or find it anywhere. I know it's probably something very simple too.
Something like:
$(this).selected('a').hover(function(){ // not sure what would come here either, I would append a css border-bottom // property to the currently selected link. That would require finding the currenlty // selected link's class and appending that css property. });
Here is what my html and css looks like for the navigation:
#nav { position:absolute; top:50px; left:480px; }
#ul#menu li { position:relative; display:inline; list-style:none; float:left; line-height:25px; }
.msize {width:70px} .msize1 {width:110px;} .msize2 {width:95px;} ul#menu li a {color:#fe4902; text-decoration:none;} ul#menu li a:hover {border-bottom:2px solid rgb(255,255,255);} ul#menu li a.selected {border-bottom:2px solid rgb(240,240,240);} /* NOT WORKING */
If anything, I would prefer to do it with CSS alone because that way if javascript is disabled I'm all good. But then again, the navigation works crystal clear except the border-bottom on links of the currently viewed page. So even if I do use JS and it's disabled, I'll still have a good looking, working menu, just without that one property.