我有这段代码
from child import *
$('#sel_kat').change(function() {
$("#" + this.value).show();
});
在CSS中设置为#sel_kat
。当我在display: none;
代码中选择一些值时,会显示<select>
div
。当我选择其他值时,如何隐藏此div?
答案 0 :(得分:1)
首先,在与Sub updt()
Dim sh1 As Worksheet, sh2 As Worksheet, lr As Long, rng As Range
Set sh1 = Sheets(1) 'Edit sheet name
Set sh2 = Sheets(2) 'Edit sheet name
lr = sh1.Cells(Rows.Count, 1).End(xlUp).Row
Set rng = sh1.Range("A2:A" & lr)
For Each c In rng
If WorksheetFunction.CountIf(sh2.Range("A:A"), c.Value) = 0 Then
sh2.Range("A" & sh2.Cells(Rows.Count, 1).End(xlUp).Row)(2) = c.Value
End If
Next
End Sub
值相关的所有div
元素上放置一个公共类。然后你可以在显示所选的一个之前隐藏它们:
select
答案 1 :(得分:0)
或者您可以隐藏最后选择的项目
$('#sel_kat').change(function() {
var lastSelect = $('#sel_kat:last').val();
$("#" + lastSelect).hide();
$("#" + this.value).show(); // show selected
});