我有兩個輸入和一個圖像......當兩個輸入都填滿後,是否可以更改圖像?當兩個輸入都填滿時更改圖像
HTML:
<div class="loginForm">
<input class="input jmeno" type="text" name="jmeno" placeholder="jmeno" value=""><br>
<div id="input_container"><input class="input heslo" type="text" name="heslo" placeholder="heslo" value="">
<img src="https://www.w3.org/2005/ajar/icons/16dot-blue.gif" id="input-blue-img">
<img src="http://www.berrylocate.com/images/dotgreen.png" id="input-green-img">
</div>
</div>
CSS:
#input-green-img {display:none;}
JS:
var $allInputs = $("input:text"),
$button = $("#input-blue-img");
$button2 = $("#input-green-img");
$allInputs.change(function() {
var isEmpty = $allInputs.filter(function() {
return ($(this).val()=="");
});
$button.hide();
$button2.show();
if(isEmpty.length == 0) {
$button.show();
}
});
的jsfiddle:https://jsfiddle.net/qeubzwvy/1/
是你可以做的,只是同時檢查是否輸入是否爲空ňkeyup事件,並相應改變圖像的SRC – RRR
查收https://jsfiddle.net/qeubzwvy/7/ – RRR