任何人都可以理解为什么我的javascript / jquery无法正常工作?感谢!!!
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')
}
我没有得到任何警报
我想通了,这只是一个小的语法错误。谢谢大家的帮助,并建议我使用控制台!
答案 0 :(得分: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')
}
应该是:
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');
}