$('form input, textarea').each(function(){
console.log($(this).prop('tagName'))
})
我不知道为什么,但上面的代码不适用于复选框和广播。我得到类型文本或数字或电子邮件的输入,但没有复选框或无线电,尽管事实也是输入。任何人吗?
编辑 - 示例代码。 jQuery看到teamSize
和projectStack
,但不是projectStage
:
<form @submit.prevent="validateForm">
<div class="form-group">
<label for="whyWorkOnProject">Why would someone want to work on the project?</label>
<textarea name="whyWorkOnProject" v-model="whyWorkOnProject" rows="3" type="text" placeholder="Please describe why would someone want to work on the project" class="form-control"></textarea><small class="invalid-feedback help-block"></small>
</div>
<div class="form-group">
<label for="teamSize">How many people work on project?</label>
<input name="teamSize" type="number" placeholder="Enter number" v-model="teamSize" class="form-control"/><small class="invalid-feedback help-block"></small>
</div>
<div class="form-group">
<label for="projectStage">What stage is project at?</label>
<div class="form-check">
<input type="radio" name="projectStage" v-model="projectStage" value="greenfield" checked="checked" class="form-check-input"/>
<label class="form-check-label">greenfield</label>
</div>
<div class="form-check">
<input type="radio" name="projectStage" v-model="projectStage" value="ongoing-development" class="form-check-input"/>
<label class="form-check-label">ongoing development</label>
</div>
<div class="form-check">
<input type="radio" name="projectStage" v-model="projectStage" value="maintenance" class="form-check-input"/>
<label class="form-check-label">maintenance</label>
</div>
</div>
<div class="form-group">
<label for="projectStack">What is the project techstack?</label>
<textarea name="projectStack" v-model="projectStack" rows="3" type="text" placeholder="Please describe technology stack" class="form-control"></textarea><small class="invalid-feedback help-block"></small>
</div>
<div class="form-group">
<label for="projectMethodology">What stage is project at?</label>
<div class="form-check">
<input type="checkbox" name="checkbox" v-model="projectMethodology" value="issue tracking tool" class="form-check-input"/>
<label class="form-check-label">issue tracking tool</label>
</div>
<div class="form-check">
<input type="checkbox" name="checkbox" v-model="projectMethodology" value="knowledge repository" class="form-check-input"/>
<label class="form-check-label">knowledge repository</label>
</div>
<div class="form-check">
<input type="checkbox" name="checkbox" v-model="projectMethodology" value="code reviews" class="form-check-input"/>
<label class="form-check-label">code reviews</label>
</div>
<div class="form-check">
<input type="checkbox" name="checkbox" v-model="projectMethodology" value="pair programming" class="form-check-input"/>
<label class="form-check-label">pair programming</label>
</div>
<div class="form-check">
<input type="checkbox" name="checkbox" v-model="projectMethodology" value="unit testing" class="form-check-input"/>
<label class="form-check-label">unit testing</label>
</div>
<div class="form-check">
<input type="checkbox" name="checkbox" v-model="projectMethodology" value="integration testing" class="form-check-input"/>
<label class="form-check-label">integration testing</label>
</div>
<div class="form-check">
<input type="checkbox" name="checkbox" v-model="projectMethodology" value="Agile/Lean/Waterfall" class="form-check-input"/>
<label class="form-check-label">Agile/Lean/Waterfall</label>
</div>
</div>
<button type="submit" class="btn btn-success">Submit</button>
</form>
答案 0 :(得分:0)
这看起来像是缩进问题,请确保您的复选框缩进正确,就像您可以使用jquery选择的其他输入一样。
答案 1 :(得分:0)
好吧,看起来这是我的愚蠢错误。控制台连接的输入相互跟随,只是没有看到左侧的数字...感谢您的耐心等待。我想我们可以删除这个问题。