0

can anyone catch why my javascript/jquery is not working? Thanks!!!

HTML (employment.php)

        <html>
    <head>
    <link rel="stylesheet" type="text/css" href="style.css">
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="resume_script.js"></script>
    </head>

    <title>Employment</title>

    <body onload="load">
        <h1>Employment History</h1>
        <button type="button" id="add_job">+</button>
        <form action="result.php">
            Start Date: <input type="text" id="start_date"> End Date: <input type="text" id="end_date"> <br><br>
            Description:<br> <textarea id="position"></textarea> <br>

            <div id="add_form"></div>

            <input type="submit">
        </form>
    <div id="footer">
            <ul>
                <li><a href="contact.php">Contact</a></li>
                <li><a href="position.php">Position</a></li>
                <li><a href="employment.php">Employment</a></li>
                <li><a href="resume.php">Resume</a></li>
            </ul>
    </div>

    </body>

    </html>

JAVASCRIPT (resume_script.js)

    $(function(){
        alert("test");
        $('#add_job').click(addJob);

    });

    function load(){
        alert("Page is loaded");
    }

    function addJob(){
        alert('test');
        $('Start Date: <input type="text" name="start_date"> End Date: <input type="text" name="end_date"> <br><br>').appendTo('#add_job')
    }

I am not getting any of my alerts


I figured it out, it was just a small syntax error. Thank you guys for all the help and recommending me to use the console!

10
  • 3
    You are missing ( and ) in addJob function. Commented Feb 4, 2013 at 16:29
  • Is the last line missing some brackets? Commented Feb 4, 2013 at 16:29
  • What do you mean I am missing the ( and )? Thanks Commented Feb 4, 2013 at 16:32
  • It should be: $('<input type="text" name="start_date"> End Date: <input type="text" name="end_date"><br><br>').appendTo('#add_job') Commented Feb 4, 2013 at 16:33
  • User your browser's console and look for the error messages. Commented Feb 4, 2013 at 16:36

1 Answer 1

2
 function addJob(){
        alert('test');
        $'Start Date: <input type="text" name="start_date"> End Date: <input type="text" name="end_date"> <br><br>'.appendTo('#add_job')
 }

Should be:

function addJob(){
        alert('test');
        $('Start Date: <input type="text" name="start_date"> End Date: <input type="text" name="end_date"> <br><br>').appendTo('#add_job');
}
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for catching that error! I just made that change, and it seems like its still not working.
This jsfiddle.net/m4S9t seems to work for me? What do you mean by "is not working"?
Hmmmm, what do you think the problem is? My resume_script is in the same folder as my php file. I am sure the problem has to do with the external, it seems like it is not reading my javascript file at all. And I can't seem to catch why.
Probably the file is cached and you still get the old file?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.