Nick Kahn
Nick Kahn

Reputation: 20078

jquery html or innerHTML?

why i am unable to display the text in my dev box?

  <script type="text/javascript">

    $(document).ready(function() 
    {
        $("facebookUserBox").innerHTML("you have not loggged in...")
    });

    var loggedIn = '<%=IsLoggedIn%>'
    if (loggedIn) 
    {
        $("facebookUserBox").innerHTML("Logged in text");
    } 

</script>


<body>
<form id="form1" runat="server">

<div id="facebookUserBox"></div> 
<br />
<br />

   User Id:  <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    Password: <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>

</form>
</body>
</html>

PS: i am not sure my jquery alignment is messed up.

Upvotes: 0

Views: 219

Answers (4)

Pierre Gayvallet
Pierre Gayvallet

Reputation: 2953

This is jQuery, not prototype use $("#facebookUserBox") instead of $("facebookUserBox")

Upvotes: 2

Andy Shellam
Andy Shellam

Reputation: 15545

You need to prefix your jQuery selector with # to tell it you're selecting an element by ID.

$("#facebookUserBox")

Upvotes: 4

nickf
nickf

Reputation: 546503

$("facebookUserBox") should be $("#facebookUserBox")

Upvotes: 3

Kemo
Kemo

Reputation: 7042

#facebookUserBox

In PrototypeJS you would use that selector, jQuery uses CSS selectors for $() function

Upvotes: 1

Related Questions