Chakreshwar Sharma Chakreshwar Sharma - 5 months ago 11
jQuery Question

Fetch the header of next div

I want to fetch the contents of div like header & other details on radio selected radio button.
I am doing like

$('input[name=subscription_plan_radio]:checked').parent().next('plan-info').html()


By doing this , I am able to fetch the contents of plan-info div, but I want to fetch the next h3 inside it.

so, I am trying
$('input[name=subscription_plan_radio]:checked').parent().next('plan-info h3').text()


but it is giving a blank string.

below is the html code.

<div class="plan-info">
<h3>
Pay Per Lead
</h3>
<div class="plan-details">
<h4 class="price">
$99
<span>month</span>
</h4>
<ul class="features">
<li>Buy Unsigned Leads</li>
<li>Price per Category from $100 to 500</li>
<li>Email Notification when a New Leads is available</li>
</ul>
</div>
</div>

Answer

You can use it like this

$('input[name=subscription_plan_radio]:checked').parent().next('.plan-info').find('h3').text()
Comments