Support

Account

Home Forums Backend Issues (wp-admin) Parent not working with admin javascript

Solved

Parent not working with admin javascript

  • Alright so i am trying to change the width of a parent element but selector parent element is just not working for me. When i do element.parent() it works just fine but when I do element.parent(‘#group’) it doesnt work at all. My current code:

    $(document).on('change', '#range-element input', function() {
    	var range_value = $(this).val() + '%';
    	$(this).parent('#group-element').css( "width", range_value );
     });
  • .parent() will only go up one level and will not find ancestors past that. Try $(this).closest('#group-element')

  • Thanks for the help John!

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Parent not working with admin javascript’ is closed to new replies.