<div class="target-form">
<form id="form">
<input name="title" typp="text" placeholder="输入一句话概括小目标,不超过20字" maxlength="20" id="title">
<textarea name="info" rows="4" placeholder="对小目标加以描述,不超过140字" maxlength="140" id="info"></textarea>
</form>
</div>
// 检测表单是否填写完整
var check = function() {
var titles=$("#title")
var info=$("#info")
console.log(titles.val())
if ($.trim(titles.val()) === "") {
return "请先填写你的目标";
}
if ($.trim(info.val())=== "") {
return "请先填写你的目标描述";
}
}
document.querySelector(".box-btn").addEventListener('click',function () {
layer.open({
type: 1,
content:$(".target-form").html(),
btn: ['确认', '取消'],
yes: function() {
var result = check();
console.log(1232)
if (result) {
layer.open({
content: result,
skin: 'msg',
time: 2
});
return;
}
})
console.log(titles.val())的时候没有看到值;而不是没有定义
![图片描述][1]
你是漏贴了吗?函数调用在哪呢。。。
能取到值。
你贴一下你的测试结果看是没看到值还是值是undefined.
只引入了部分文件,但是也能看到是有值的。