function selectOnchang(obj) { var selectedValue = obj.selectedIndex if (selectedValue == 0) { obj.parentNode.nextSibling.style.display = 'none' obj.parentNode.nextSibling.nextSibling.style.display = 'inline' }else if (selectedValue == 1) { obj.parentNode.nextSibling.style.display = 'inline' obj.parentNode.nextSibling.nextSibling.style.display = 'none' } }
$("select[name='source_type']").each(function (index, item) { $(this).val(data.cameras[index].source_type) if (data.cameras[index].source_type == 0) { $(this).parent('.form-group').next().hide() $(this).parent('.form-group').next().next().show() } else { $(this).parent('.form-group').next().show() $(this).parent('.form-group').next().next().hide() } })
标签:style,遍历,obj,form,dom,nextSibling,next,group,节点 From: https://www.cnblogs.com/ljingjing/p/17005070.html