当前位置: 动力学知识库 > 问答 > 编程问答 >

jQuery hide multiple objects with one method

问题描述:

I have multirow table and I want to hide some of them on click event. How can I do it with single method

 <script type="text/javascript">

function createInputForm(){

var rtype = $('#rtype').val();

var md = $('#tr_md'),reg = $('#tr_reg'),trans = $('#tr_trans'),;

$('#table_input_new tr').fadeIn();

if(rtype=='A'){

$(md,reg).fadeOut();

}

else if(rtype=='B'){

$(reg,trans).fadeOut();

}

}

$('#rtype').change(createInputForm);

-->

</script>

网友答案:

You need to use add method to add one jQuery collection to another:

if (rtype == 'A') {
    md.add(reg).fadeOut();
}
else if (rtype == 'B') {
    reg.add(trans).fadeOut();
}
分享给朋友:
您可能感兴趣的文章:
随机阅读: