I have several input text element,
I have button disable some input for disable some input element(s),
I have also button see values, for see all input values,
What I need:
for example I click on button disable some input, now some inputs are disabled right?
and now if click on button see values, I want see only that input values, which are not disabled.
I make almost all, but I dont know, how make this condition: if element already is disabled
please see demo
http://jsfiddle.net/WW8UF/4/
The body is:
<form>
<ul id="my_ul">
<li><input type="text" value="a" /></li>
<li><input type="text" value="s" /></li>
<li><input type="text" value="d" /></li>
</ul>
</form>
<div id="disable_btn">disable some input</div>
<div id="see_values">see values</div>
The js, using jQuery 1.8.2
$(document).ready( function () {
$("#disable_btn").on("click", function () {
$("#my_ul li:eq(0) input").prop("disabled", true);
});
$("#see_values").on("click", function () {
$("#my_ul li").each ( function () {
if (1==1/*if this input is not disabled*/) {
alert ( $(this).find("input").val() );
}
});
});
});
No need to loop over every
li, just get the inputs which are not disabled:Live example: http://jsfiddle.net/WW8UF/10/
You could also use
Which is a bit cleaner. Live example: http://jsfiddle.net/WW8UF/11/