yerassyl
yerassyl

Reputation: 3048

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?

Upvotes: 0

Views: 156

Answers (3)

Łukasz Florczak
Łukasz Florczak

Reputation: 83

Yo can add class selector to siblings():

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

Upvotes: 1

Satpal
Satpal

Reputation: 133403

You can pass selector to .siblings() method

var slots = $('.clinic-branch-2.doctor-has-specialty-3').parent().siblings('.slots-go-here');
slots.html('Do Something')

Upvotes: 1

callback
callback

Reputation: 4122

$.siblings can take a selector. see docs.

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

Upvotes: 2

Related Questions