简体   繁体   中英

Jquery/Javascript external file is not working

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!

 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');
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM