0

hi folks
I have this following code but it gives me "invalid argument" error when I click on the 'a tag'. what is my mistake ?

<script type="text/javascript">
    $(function () {
        $('#click').click(function () {
            $get('log').style.top = (screen.y / 2).toString();
            $get('log').style.left = (screen.x / 2).toString();
            $('#Log').show();
        });
    });
</script>
     <a id="click">[to login click here]</a>
                <div id="Log" style="display: none; position:absolute; top: -29px; left: 569px;">
                    <div style="text-align: center; vertical-align: middle; height: 316%;">
                        <asp:Login ID="Login1" runat="server" BackColor="#F7F6F3" BorderColor="#E6E2D8" BorderPadding="4"
                            BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em"
                            ForeColor="#333333" DestinationPageUrl="~/Account/Default.aspx" DisplayRememberMe="False">
                            <InstructionTextStyle Font-Italic="True" ForeColor="Black" />
                            <LoginButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1px"
                                Font-Names="Verdana" Font-Size="0.8em" ForeColor="#284775" />
                            <TextBoxStyle Font-Size="0.8em" />
                            <TitleTextStyle BackColor="#5D7B9D" Font-Bold="True" Font-Size="0.9em" ForeColor="White" />
                        </asp:Login>
                    </div>
                </div>        
kamiar3001
  • 2,646
  • 4
  • 42
  • 78

4 Answers4

1

why mix $get and $?

just using jquery you can set the top and left...

$('#log').css('top',(screen.y / 2).toString() + 'px');

and I hope your script isnt like that in the code, just before the html in the page? If it is, then move your scripts to the bottom before closing the </body> tag.

Moin Zaman
  • 25,281
  • 6
  • 70
  • 74
  • $(function(){}) is short hand for waiting for the document to be ready so its not really a problem. I'm pretty sure his click event is registered. I agree though. I'm not familiar with $get but I think he either needs $get("#Log") or just use .css on the jquery object after getting the log div. – John Hoven Sep 03 '10 at 20:19
  • it doesn't work my script is before the

    tag but it did't effect on top an left attribute my click was handled but top and left didn't effect

    – kamiar3001 Sep 03 '10 at 20:34
0

Try wrapping your jQuery in this:

$(document).ready(function() { ... }

Also, are you importing the jQuery framework?

If you have downloaded it locally:

<script src="jquery.js" type="text/javascript"></script>
Andy_Vulhop
  • 4,699
  • 3
  • 25
  • 34
0

Using the current version of jQuery, I would do something along the following line:

$("#click").live("click", function() { ... });

instead of the .click as that would allow it to bind as loaded. No need for the $(document).ready();

David Williams
  • 823
  • 6
  • 16
0

I think the best one was answered before.

Community
  • 1
  • 1
kamiar3001
  • 2,646
  • 4
  • 42
  • 78