我需要从数据列表中获取值吗?目前,我为2参数yoursign和friendsign定义了例如,如果我为您的手势选择白羊座,为friendSign选择狮子座,则我需要同时获取两者并传递给函数 <body> <form id="Match"></form><label for="yourSignList">your sign:</label><br /><input list="yourSignList" name="sign1" required><br /><datalist id="yourSignList"> <option value="Aries"> <option value="taurus"> <option value="Gemini"> <option value="Cancer"> <option value="Leo"> <option value="Virgo"> <option value="Libra"> <option value="Scorpio"> <option value="Saggitarius"> <option value="Capricon"> <option value="Aquarius"> <option value="Pisces"></datalist><label for="friendSignList">your friend sign:</label><br /><input list="friendSignList" name="sign2" required><br /><datalist id="friendSignList"> <option value="Aries"> <option value="taurus"> <option value="Gemini"> <option value="Cancer"> <option value="Leo"> <option value="Virgo"> <option value="Libra"> <option value="Scorpio"> <option value="Saggitarius"> <option value="Capricon"> <option value="Aquarius"> <option value="Pisces"></datalist><button type='submit' onclick="Match()">Done</button><br><label for="output">התאמה: </label><output id='output'></output><form /><script> function Match() { const signYours = $("yourSignList").val(); const signFriend = $("friendSignList").val(); $("#output").val(answer(signYours, signFriend)); }
2 回答
红糖糍粑
TA贡献1815条经验 获得超6个赞
试试这个代码可能像
$("#friendSignList").find("option").each(function(e,i){ console.log( e, i );});
aluckdog
TA贡献1847条经验 获得超7个赞
这对我有用:
function Match() {
var signYours = $("input[name='sign1']").val();
var signFriend = $("input[name='sign2']").val();
$("#output").val(answer(signYours, signFriend));
}
添加回答
举报
0/150
提交
取消