如果主類文本框的值與用戶匹配,但是我想將主用戶類與用戶類進行比較並打印數量計數導致有多少輸入用戶類具有與主站具有相同重複值的div。Javascript計數在文本框中重複的時間相同的值的數量
HTML:
<input class="master" value="1">
<input class="user" value="1">
<input class="user" value="1">
<input class="user" value="0">
<input class="user" value="0">
<div id="result_count"></div>
的Javascript:
$(function() {
var master = $('input.master').get(0).value; // get the master value
var fn = function() {
return this.value === master ? "yes" : "no";//if current text-box matches master,then yes else no
};
$('input.user').val(fn); // loop and replace text for each user input
});
什麼是輸入'type'? – hjpotter92
@ hjpotter92這是全部文字 – Shaik
@Shaik檢查我的答案它將輸出2,因爲2級用戶的輸入與主人的價值相同 – guradio