I've been making a jQuery plugin for password boxes. It adds a generate password button and strength indicator to inputs that are passed to it via a jQuery selector.
I'm having an issue with the code on lines 154 & 155 of jquery.password.js inputPassword.position().top
. It's not returning the correct position of the input box, so the error message isn't appearing in the correct place.
I think this is probably an issue with inputPassword
not being in the correct namespace, or something like that, but I don't fully understand how these things work in javascript... this is my first jQuery plugin.
Thanks
** link removed ***
It wasn'开发者_JS百科t namespaces, it was because the object was hidden. So fixed with:
if ( inputPassword.is(":visible") ) {
positionObject = inputPassword;
} else {
positionObject = inputPlain;
}
position()
returns the offset relative to the parent, however, as the element you're trying to position is positioned absolutely, you might find it works if you use offset()
instead.
Edit: inputPassword
is hidden whilst you're retrieving the offset()
/ position()
. From the docs: Note: jQuery does not support getting the offset coordinates of hidden elements.
精彩评论