[Solved] how to find a parent class and its children


Assuming you have the hierarchy as shown in your description and if, for example, you have the Order_Coupon element selected, you can get the coupon amount by the .children method.

var amount=$('.Order_Coupon').children().html();

Depending on what you have selected, you may have to use multiple calls of .child to find the coupon_amount element.

var amount=$('.Order_Left').children().children().children().html();

However, if each of these elements have ids or classes, it’s much safer to use the .find method and specify a selector. Find also searches further than one child layer.

var amount=$('.Order_Left').find('.Coupon_Amount').html();

This way you ensure you get the value of the correct element. If there are more than one child element any of the div’s you call .children on, without specifying a selector, you are likely to get very incorrect results.

2

solved how to find a parent class and its children