继承人的代码得到一个空值谁能帮助,告诉我为什么我在功能
这是脚本
<script>
$(document).ready(function(){
$('#done_edit').click(function(){
var name= document.getElementById('first_name').value;
alert(name);
});
});
这是形式
<form id="passedit" class="submit">
<label>First Name:</label><input type="text" name="first_name" class="form-control" value="<?php echo $row['name'];?>" />
<button type="submit" class="btn btn-info" id="done_edit" >DONE<span class="glyphicon glyphicon-check"></span></button>
我看不出它有ID'first_name' –
也是为了找出值使用'.value'元素。 –
您应该[了解如何正确使用标签元素](http://www.456bereastreet.com/archive/200711/use_the_label_element_to_make_your_html_forms_accessible/)。如果没有for属性或者表单控件,标签就没用了。 – Quentin