Bladephp: Now with 8+ codeigniter, php, and laravel project 8+ php project From $37/Month From Rs. 2499/Month

How to remove option to select list using jQuery

by
Category:javascript
javascript jquery
How to remove option to select list using jQuery

jQuery provides some interesting methods that would help remove items (options) in the select element. You can remove specific (single) item using value in option.

HTML Code

<select id="paid_by" name="paid_by">
    <option value="">Select Payment Method</option>
    <option value="1">Cash</option>
    <option value="3">Credit cards</option>
    <option value="5">Cheque</option>
    <option value="6">Debit / Credit Sales </option>
    <option value="7">Gift Card</option>
    <option value="8">Deposit</option>
    <option value="10">Free</option>
    <option value="11">Points</option>
    <option value="13">Dialog Cards </option>
    <option value="14">Visa / Master</option>
    <option value="15">Amex</option>
    <option value="16">P B Visa</option>
    <option value="17">vouchers</option>
    <option value="19">Excess</option>
    <option value="9">Shortage Account</option>
</select>

jQuery Code

$("#paid_by option[value='9']").remove();

Output

<select id="paid_by" name="paid_by">
    <option value="">Select Payment Method</option>
    <option value="1">Cash</option>
    <option value="3">Credit cards</option>
    <option value="5">Cheque</option>
    <option value="6">Debit / Credit Sales </option>
    <option value="7">Gift Card</option>
    <option value="8">Deposit</option>
    <option value="10">Free</option>
    <option value="11">Points</option>
    <option value="13">Dialog Cards </option>
    <option value="14">Visa / Master</option>
    <option value="15">Amex</option>
    <option value="16">P B Visa</option>
    <option value="17">vouchers</option>
    <option value="19">Excess</option>
</select>

0 Comments


Html code work in comment box


Related Post