#7774 closed bug (invalid)
set offset lead to show() method failed
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | 1.6 |
Component: | unfiled | Version: | 1.4.4 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description (last modified by )
$( "#ContactBtn" ).bind( "click", function(evt) { var offset = $(this).offset(), newOff = {}; newOff.left = offset.left - 250; newOff.top = offset.top - 350;// $( "#ContactPanel" ).offset( newOff ).show(); });
when I click ContactBtn,first it show,but when I use ("#ContactBtn").hide()
It must click twice to show the div panel;
I'm not sure it's a bug;
But,
$( "#ContactBtn" ).bind( "click", function(evt) { var x, y; if( typeof window.event != 'undefined' ){ x = evt.clientX; y = evt.clientY; } else { x = evt.pageX; y = evt.pageY; } $( "#ContactPanel" ).css( "top", y - 350 + "px" ) .css( "left", x - 250 + "px" ) .show(); });
It's work; I'm sorry my poor English;
Change History (4)
comment:1 Changed 12 years ago by
Owner: | set to [email protected]… |
---|---|
Status: | new → pending |
comment:2 Changed 12 years ago by
test url:http://jsfiddle.net/sPMGM/1/ I found that I click the button div every time,the offset() method's final result different. I use IE8,and set overflow hidden,so it disappear;
comment:4 Changed 12 years ago by
Description: | modified (diff) |
---|---|
Resolution: | → invalid |
Status: | new → closed |
Thanks for reporting back with and providing a test case!
This isn't a bug in jQuery. The offset() documentation states
jQuery does not support getting the offset coordinates of hidden elements.
which explains your problems. That it works the first time is only a "coincidence" because at that time top/left
are 0
. Just change .ContactPanel
top/left
to something different from 0px
and then it also won't work on the first click.
The correct way to go about this is to use .css()
working test case based on your code
Please provide a reduced test case on jsFiddle demonstrating this issue. Also, please tells us what browser you experienced this issue in.