以下 HTML:<div class="form-inline"> <span>Name:</span> <input id="name" type="text" class="form-control" placeholder="Name eingeben..." required/></div><div class="form-inline"> <span>Tierart:</span> <input id="species" type="text" class="form-control" placeholder="Tierart eingeben..." required/></div><div class="form-inline"> <span>Rasse:</span> <input id="breed" type="text" class="form-control" placeholder="Rasse eingeben..." required/></div><div class="form-inline"> <span>Chip-Nummer:</span> <input id="chipnr" type="text" class="form-control" placeholder="Chip-Nummer eingeben..."/></div>在脚本标签中,我将值放入字典中:var data = { name: $("#name").val(), species: species.value, breed: breed.value, chipnr: chipnr.value}参加方式适用于其他字段,但不适用于名称字段,在字典中名称是“未定义”,为什么以及如何更改它?
1 回答
摇曳的蔷薇
TA贡献1793条经验 获得超6个赞
将值的来源更改为 jquery select by id of element:
var data = {
name: $("#name").val(),
species: $("#species").val(),
breed: $("#breed").val(),
chipnr: $("#chipnr").val()
}
- 1 回答
- 0 关注
- 87 浏览
添加回答
举报
0/150
提交
取消