javascript - div not loading in right place -


hi im trying load div next link/button if clicked unauthenticated users.

i have following:

$(function () {      $(".unauthenticated").click(function () {         showmessage($(this).attr("id"), "#unauthenticated-div")     });      function showmessage(clickeditemid, divid) {          clickeditem = $("#" + clickeditemid);         var pos = clickeditem.offset();         var width = clickeditem.width();          $(divid).css({             "left": pos.left + width + 10,             "top": pos.top + 10         }).show();     } });  <div id="unauthenticated-div" title="please login" style="display: none;">     <p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;">     </span>you must <a href="#" id="login-link">login</a>or <a href="/account/register/">register</a>to this</p> </div> 

it shown div, not next clicked link. when step through code, pos , width expected.

does element on you're setting position have position property set absolute or relative?

if not, try setting it.

    $(divid).css({         "left": pos.left + width + 10,         "top": pos.top + 10,         "position":"absolute"     }).show(); 

also, updated question html doesn't show element class "unauthenticated".

not sure if that's part of issue, click being assigned $(".unauthenticated").


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -