简体   繁体   中英

make visible div on dropdown select in jquery

I am developing the asp.net mvc application . my one of forms requirement is that: It has dropdown filling up with let say A,B,C values. If selected A then on UI there should be 2 text boxes should be visible and other should be invisible , if selected B, then must be add another 2 text boxes , i this way there should be 4 text boxes. same for selection of C. I able to get the selected value by

$(document).ready(function() {

    $('#NatureOfTransactionDropDown').change(function() {

        var element = $(this).find('option').filter(':selected').text();
        alert(element);
        if (element == "A") {
           //code
          }
    });
});

What I have to do. I tried hide() show(), but i think it is not working for me.

use .css("display", "none"); for hiding,
and .css("display", "block"); for showing

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM