Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery Remove input with value x

Tags:

jquery

input

Guys how can i remove an input with a specific value using jquery?

I know i should user .remove() but i don't know how to find the specific input.

like image 605
Antonio Ciccia Avatar asked May 10 '12 10:05

Antonio Ciccia


2 Answers

$("input[value='"+value+"']").remove();

Where value is the value of the element you want to delete. :)

like image 150
Prasenjit Kumar Nag Avatar answered Sep 24 '22 20:09

Prasenjit Kumar Nag


Loop into the <input> fields then match each values, if match, then remove it:

$(document).ready(function() {
    $('input[type=text]').each(function() {
        if ($(this).val() === "foo") {
            $(this).remove();
        }
    });
});​

Demo here jsFiddle.

like image 28
deex Avatar answered Sep 26 '22 20:09

deex