Skip to main content
1 of 2
Inaimathi
  • 2.2k
  • 12
  • 24

This...is pretty bad. But there's no real way to tell how bad it has to be given other constraints. For instance, if this is a JS file meant to affect a page whose HTML you don't have control over, then you can't do much better than something like

$(this).parents(":eq(5)").children(":eq(0)").html()

If this is an element you have to access a lot, consider adding an id or class to it, then selecting by that.

$("#fifth-parent-first-child").html() //or something descriptive

Again, if you don't have access to the HTML, you'll need to add it yourself at runtime

$(document).ready(
     function () {
         $(this).parents(":eq(5)").children(":eq(0)").addClass("something-descriptive")
     }
);
$(".something-descriptive").html()

Consider pasting some surrounding code for more insight.

Inaimathi
  • 2.2k
  • 12
  • 24