如果选项未选中语句

时间:2016-09-27 13:15:49

标签: javascript jquery css

我有下拉选择和这样的选项:

<div class="input-field">
 <span class="icon-area"></span>
 <select>
  <option value="0">list 0</option>
  <option value="1">list 2</option>
  <option value="2">list 3</option>
 </select>

如果未选择列表0我想添加css样式但我的js代码不起作用

$("select").blur(function() {
        $(this).parents(".input-field").removeClass("form-border");
        $(this).parents(".input-field").find(".icon-area").removeClass("form-background");

        if(this.value){
            $(this).parents(".input-field").addClass("form-border");
            $(this).parents(".input-field").find(".icon-area").addClass("form-background");
            return false;
        }else{
            $(this).parents(".input-field").removeClass("form-border");
            $(this).parents(".input-field").find(".icon-area").removeClass("form-background");
            return false;
        }
    });

出了什么问题?

1 个答案:

答案 0 :(得分:2)

尝试替换为:

Sub Splt()
    Dim LR As Long, i As Long
    Dim X As Variant
    Application.ScreenUpdating = False
    LR = Range("A" & Rows.Count).End(xlUp).Row
    Columns("A").Insert
    For i = LR To 1 Step -1
        With Range("B" & i)
            If InStr(.Value, ",") = 0 Then
                .Offset(, -1).Value = .Value
            Else
                X = Split(.Value, ",")
                .Offset(1).Resize(UBound(X)).EntireRow.Insert
                .Offset(, -1).Resize(UBound(X) - LBound(X) + 1).Value = Application.Transpose(X)
            End If
        End With
    Next i
    Columns("B").Delete
    LR = Range("A" & Rows.Count).End(xlUp).Row
    With Range("B1:C" & LR)
        On Error Resume Next
            .SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
         On Error GoTo 0
         .Value = .Value
    End With

    Application.ScreenUpdating = True
End Sub