Wie Entferne ich bestimmte Elemente mit einem jQuery .each-Schleife?

Nehme an, ich habe ein HTML-Dokument mit:

<form id = "my_form">
    <input type = "text" />
    <input type = "text" />
    <input type = "text" />
    <button type = "button" onclick = "removeGoodInputs()">Do the job</button>
</form>

Ich loswerden wollen der Eingänge Werte erfüllen einer Bedingung (in meinem JS). Ich habe versucht, meinen removeGoodInputs() Funktion (wie unten), aber dies löscht alle Eingaben aus dem Formular. Wie kann ich dieses Problem beheben?

function removeGoodInputs() {
    $("#my_form input").each(function() {
        if(this.attr("value") == 10)
            $(this).remove();
    });
}
InformationsquelleAutor patryk | 2012-09-09
Schreibe einen Kommentar