Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Undefined?

  1. #1
    New to the CF scene
    Join Date
    Jun 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Undefined?

    I am doing a simple chat app and I am having some problems with when I type in something and press send it posts "undefined"? Any help/answers?
    Jquery
    Code:
    $(document).ready(function() {
       $('.draft').mouseenter(function(){
       $(this).css('outline-color','purple');
       }); 
       $('button').click(function() {
        	var toAdd = $('draft').val();
            $('.messages').append("<p>"+toAdd+"</p>");
        });
    });
    Css
    Code:
    .container {
    height:750px;
    width:800px;
    position:center;
    border:red solid 5px;
    margin-left:500px
    }
    .draft{
    margin-left:500px;
    border:black solid 1px
    ;width:727;
    height:50;
    margin-top:3
    }
    
    .send{
    margin-top:3;
    margin-left:f
    border: black solid 1px;
    height:50;
    width:80
    }
    HTML
    Code:
    <html>
      <head>
      <script>  </script>
       <link type="text/css" rel="stylesheet" href="stylesheet.css"/>
        <script src = "http://code.jquery.com/jquery-1.10.1.js"></script>
        	<script type='text/javascript' src='script.js'></script>
    	<script>	</script>
    	<script src="http://chatmaker.herokuapp.com/ChatBuilder.js"></script>
      </head>
      <body>
     
    <div class="container">
    <div class="messages"> </div>
    
    
    
    </div>
        
        <div>
          <input class="draft" type="text"/> <button class="send">send</button>
          <ul class="messages"></ul>
        </div>
      
    
      </body>
    </html>
    You can ignore <script src = "http://code.jquery.com/jquery-1.10.1.js"></script>
    It is for later in the project.

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,784
    Thanks
    6
    Thanked 1,022 Times in 995 Posts
    You forgot the period in front of the class name: var toAdd = $('.draft').val();


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •