TellJohn TellJohn - 3 months ago 9
jQuery Question

target a div outside of my Jquery button element

I'm trying to target a div outside of my Jquery button element. The way I'm doing it right now is

$(this).parent().parent().parent().parent().parent().parent().parent().children(":nth-child(3)").children().children().children(":nth-child(4)");


There must be and easier way? The element has a class but there are more identical elements I also need to adjust individually.

Thanks.

CODE:
https://jsfiddle.net/n71mgmgw/

Answer

Maybe use something like:

$(this).closest('.pucontent').find('input.fontSize').val(); // You'll get font size.
// or
$('input.fontSize', $(this).closest('.pucontent')).val();

Read about .closest() and .find() or better read article about traversing in jQuery

Comments