我想要做一个配置文件管理功能,因为我想添加类型的用户是学生到其他类型的用户是老师的数据库为我使用我使用jquery和ajax但我正面临一个问题,即每个学生都有一个添加按钮,这些按钮在html页面中列出(这是使用php从数据库中选择完成的),当我按下每个学生的添加按钮时,我在警报框中获得未定义HTML的从最近的点击按钮获得价值
部分
<li class="studdet">
<div class="row">
<div class="col-md-6" id="studname">
<div class="col-md-3" id ="all">
<label>Name Of Student:</label>
<p id="nameOfStud" >name of student fetched from database</p>
</div>
<div class ="col-md-3">
<label></label>
</br></br>
<button class="btn-u" id="addStudents">Add</button>
</div>
</div>
</div>
</li>
<li class="studdet">
<div class="row">
<div class="col-md-6" id="studname">
<div class="col-md-3">
<label>Name Of Student:</label>
<p id="nameOfStud" >Name of student fetched from data base</p>
</div>
<div class ="col-md-3">
<label></label>
</br></br>
<button class="btn-u" id="addStudents">Add</button>
</div>
</div>
</div>
</li>
的jQuery的流汗学生姓名的值是
$(document).on('click', '#all #addStudents', function() {
var option = $(this).closest("id","nameOfStud").html();
alert(option);
// $.ajax({url: "http://localhost/ededge/Add_students/add_to_group",data: {studentname : option},type:"POST", success: function(result){
// $('#studdet').attr('class','label label-light');
// alert(result);
// }});
});
但什么我得到的警告框是未定义
帮我找到我的错误,如前
固定的HTML标记是不正确的 – guradio