SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2010
    Location
    Uk
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    error: missing ":" after property id

    I just don't seem to get my head around this problem. as far as i'm concerned the javascript/jquery code should work. Any ideas where i'm going wrong?

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <title>jQuery</title>
        
    <script type="text/javascript"
     src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
    <script type="text/javascript">
    
    $(document).ready({
        $('#sub').click(function(){
            alert('work!!');
        });
    });
    
    </script>
    
    </head>
    <body>
        <form action="" method="post">
            <p>Name
        <input type="text" name="fname" id="nom"></p>
            <p>Last Name
        <input type="text" name="sname" id="snom"></p>
            
        <input type="submit" name="sub" id="sub">
    </body>
    </html>
    The error i'm getting says "error: missing ":" after property id"

    thank you

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,183
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    The way you wrote your code is telling the jQuery method .ready() your passing an object array to it, the correct code should be a function

    Code JavaScript:
    $(document).ready(function(){
        $('#sub').click(function(){
            alert('work!!');
        });
    });
    Blog/Portfolio | Evolution Xtreme | DFG Design | DFG Hosting | CSS-Tricks | Stack Overflow | Paul Irish
    Having lame problems with your code? Let us help by using a jsFiddle

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2010
    Location
    Uk
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oh yes so true... works fine now. Thanks I feel so stupid

  4. #4
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,183
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    No problem, don't feel bad bud. Happens to all of us at a point
    Blog/Portfolio | Evolution Xtreme | DFG Design | DFG Hosting | CSS-Tricks | Stack Overflow | Paul Irish
    Having lame problems with your code? Let us help by using a jsFiddle


Bookmarks

Posting Permissions

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