如何在特定div之前和之后检查div

时间:2016-02-26 13:32:46

标签: javascript jquery html css

我有一个名为.options.selected的班级。我想知道我是否能够选择之前的.line以及使用jQuery之后?

<div class="options-label">Price:</div>
<div class="options first">$0 - $100</div>
<div class="line"></div>
<div class="options">$100 - $200</div>
<div class="line"></div>
<div class="options">$200</div>
<div class="line"></div>
<div class="options selected all">All</div>
<div class="line"></div>

4 个答案:

答案 0 :(得分:1)

前一个div需要.prev(),下一个需要.next()

 var prevDiv = $('.options.selected').prev('.line'),
        nextDiv = $('.options.selected').next('.line');

答案 1 :(得分:0)

dataType: 'json'

答案 2 :(得分:0)

<强> JQuery的

cordova platform rm browser
cordova platform add browser
cordova build browser
cordova run browser

或者:

Private Sub Worksheet_Change(ByVal Target As Range)

Dim nextTarget As Range

Set nextTarget = Range(Selection.Address) 'store the next range the user selects

If Target.Column = 1 Then

    Target.Columns.Select 'autofit requires columns to be selected
    Target.Columns.AutoFit

    nextTarget.Select
End If
End Sub

答案 3 :(得分:0)

你可以使用jQuery:

$(document).ready(function(){

  var prev = $('.options.selected').prev('.line');
  var next = $('.options.selected').next('.line');

});

Demo here