jQuery - retrieve id of parent DIV.

Hi,
I have a function "eventChange" that gets triggered when a select statement in div with class "frequency" changes.

Is there a way to also retrieve the id of the parent div with class tab_group ?      

Thanks in advance for your help.


$('.frequency select').change( eventChange );

 
function eventChange() {
  var factor = { D: 365, W: 52, F: 26, M: 12, Q:4, Y: 1 };
  var year_amount = $(this).closest(".newline").find(".amounts").val();
  $(this).closest(".newline").find(".yearly-amounts").val( year_amount * factor[$(this).val()] );
  totalChange(this);
   

}
 
<div class="tab_group" id="tabs-1">
            <div class="budget_group">Income</div>
			       
			
			<div class="newline">
			<input name="rec_id[3]" type="hidden" value="3">
            <div class="description"><input class="description-text" name="description3" type="text" value="Your take-home pay"></div>
			<div class="frequency">
			<select onChange="setValue(this.value);" name="frequency3">
					  <option value="D" >Daily</option>
					  <option value="W" >Weekly</option>
					  <option value="F" >Fortnightly</option>
					  <option value="M" SELECTED>Monthly</option>
					  <option value="Q" >Quartely</option>
					  <option value="Y" >Annually</option>
			  </select>
			</div>
			<div class="frequency-total"><input class="amounts" name="frequency-total3" type="text" value="600"></div>
			<div class="yearly-total"><input class="yearly-amounts" readonly name="yearly_total3" type="text" value="7200"></div>
			
			</div><!-- end of newlin -->
			
			       
			
			<div class="newline">
			<input name="rec_id[4]" type="hidden" value="4">
            <div class="description"><input class="description-text" name="description4" type="text" value="Your partner's take-home pay"></div>
			<div class="frequency">
			<select onChange="setValue(this.value);" name="frequency4">
					  <option value="D" >Daily</option>
					  <option value="W" >Weekly</option>
					  <option value="F" SELECTED>Fortnightly</option>
					  <option value="M" >Monthly</option>
					  <option value="Q" >Quartely</option>
					  <option value="Y" >Annually</option>
			  </select>
			</div>
			<div class="frequency-total"><input class="amounts" name="frequency-total4" type="text" value="2"></div>
			<div class="yearly-total"><input class="yearly-amounts" readonly name="yearly_total4" type="text" value="52"></div>
			
			</div><!-- end of newlin -->
			
			       

			
						<div class="newline"><a href="/index.php?page=budget_planner&update=add_line&budget_group=Income&budget_type=I&from_tab=tabs-1" target="_self">+ Add another line to Income</a> </div>
       
       <div class="newline">Total - Income =  <span class="group-total">23312.00</span></div>
       
       <input name="group1" type="hidden" class="hidden-group-total" value="23312.00">
 
<button class="get_tab_number">Get Tab Number 1</button>
 
</div><!-- end of tab -->
 
 
 
			
            <div class="tab_group" id="tabs-2">
            <div class="budget_group">Financial Commitments</div>
			       
			
			<div class="newline">
			<input name="rec_id[10]" type="hidden" value="10">
            <div class="description"><input class="description-text" name="description10" type="text" value="Rent/Mortgage"></div>
			<div class="frequency">
			<select onChange="setValue(this.value);" name="frequency10">
					  <option value="D" >Daily</option>
					  <option value="W" >Weekly</option>
					  <option value="F" >Fortnightly</option>
					  <option value="M" >Monthly</option>
					  <option value="Q" SELECTED>Quartely</option>
					  <option value="Y" >Annually</option>
			  </select>
			</div>
			<div class="frequency-total"><input class="amounts" name="frequency-total10" type="text" value="2800"></div>
			<div class="yearly-total"><input class="yearly-amounts" readonly name="yearly_total10" type="text" value="11200"></div>
			
			</div><!-- end of newlin -->
			
			       
		
						<div class="newline"><a href="/index.php?page=budget_planner&update=add_line&budget_group=Financial Commitments&budget_type=I&from_tab=tabs-2" target="_self">+ Add another line to Financial Commitments</a> </div>
       
       <div class="newline">Total - Financial Commitments =  <span class="group-total">24895.00</span></div>
       
       <input name="group2" type="hidden" class="hidden-group-total" value="24895.00">
 
<button class="get_tab_number">Get Tab Number 2</button>
 
</div><!-- end of tab -->

Open in new window

sabecsAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
leakim971Connect With a Mentor PluritechnicianCommented:
var id = $(this).closest("div.tab_group").attr("id");
0
 
sabecsAuthor Commented:
Thanks..
0
All Courses

From novice to tech pro — start learning today.