yerassyl yerassyl - 4 years ago 161
jQuery Question

Select element inside other matched set of elements in JQuery

Suppose I have following selector:

var slots = $('.clinic-branch-2.doctor-has-specialty-3').parent().siblings();


which gives me this result:

[div.col-xs-3.col-sm-3.col-md-2, div.col-xs-4.col-sm-4.col-md-4.slots-go-here, prevObject: m.fn.init[1], context: document]


What I need is to select
.slots-go-here
element.
I tried to access it with
[1]
index, however it returns raw HTML. Later I need to call
.html(someHtmlString)
on my selection. How can I do that?

Answer Source

$.siblings can take a selector. see docs.

$('.clinic-branch-2.doctor-has-specialty-3').parent().siblings('.slots-go-here');

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download