English 中文(简体)
jquery animate, by hover
原标题:jquery animate one element by hover over another

我成功地(几乎几乎) j笑了,但现在需要一个案文,说“......”在我 h忙时出现,而这一事件又使情况更加广泛。 这项活动使散射过程在进入后更加宽广,在离开后更缩小。

因此,我希望的是:

if($( this).width() >= "25") //  if the width is greater than 25
    $("#clickme").css( opacity , 0) // - effect a DIFFERENT id which is my "click.."

and of course upon mouse leave, do the opposite. I can t get this to work thus far

http://pastebin.com

任何杂质?

最佳回答

If you want to position a div over another elements, you can use a fixed or absolute positioning with css. You can get the position of the current element that is being hovered upon with:

.offset()

rel=“nofollow”>http://api.jquery.com/offset/

Then use offset() to set the position of your hovering div. If you want the div to hover over everything, its best to put it as the first element of the body.

问题回答

This accomplishes what you want. It uses the .hover() function to assign two handlers to the object, one on mouse in, one on mouse out.

$( .selector ).each(function() {
        var clicktext = null;
        $(this).hover(function() {
                var pos = $(this).offset();
                // add the click text and assign it to the proper variable
                // this code can be changed to what ever it takes for your code
                // just make sure to leave the zIndex at a greater than 0 value
                // and the position values as they are. Padding, etc. are optional.
                clicktext = $( <div> ).css({
                        zIndex: 1000,
                        padding: "2px",
                        position: "absolute",
                        left: pos.left,
                        top: pos.top
                }).text("click").appendTo( body );
        }, function() {
            clicktext.remove();
        });
});

- Sunjay03





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签