0

I'm making a Chrome Extension for Roblox, and I need to wait for all of the children of a certain element to load so I can do stuff with them. Currently, this logs all of the elements as they are added, but I need to dig deeper in their children to find class "game-card-name", but it seems to be non-existent whenever I do $(e).find("game-card-name")

console.log("Roblox Bookmark Loaded");

$(document).on("DOMNodeInserted", function(e) {
    if ($(e.target).hasClass("game-card")) {
        console.log(e);
    }
});

What I need is a way to search in jQuery, and wait for an element to exist, and possibly yield until an attribute is present. If anyone has a jQuery answer, please post!

EDIT: I was not doing $(e.target). I solved this

  • _"but it seems to be non-existent whenever I do `$(e).find("game-card-name")`"_ The code at Question checks for `if ($(e.target).hasClass("game-card"))`. Is the issue that you are trying to match the incorrect `.className`? Which `.className` are you checking for? – guest271314 Aug 12 '17 at 18:02
  • I do `$(e).find("game-card-name")` inside of the if statement. Sorry if I was unclear. @guest271314 – AlreadyPro Aug 12 '17 at 18:12
  • https://www.w3schools.com/code/tryit.asp?filename=FIHHPMNA2SFF – Laurianti Aug 12 '17 at 18:14
  • You dismissed @spanky 's Answer, though their Answer is accurate as to that specific issue at code at Question – guest271314 Aug 12 '17 at 18:14

1 Answers1

0

but I need to dig deeper in their children to find class "game-card-name", but it seems to be non-existent whenever I do $(e).find("game-card-name")

You're missing the . in the selector to find the class.

//---------v
$(e).find(".game-card-name")

Your selector was looking for elements with the tag name, like <tame-card-name>.

spanky
  • 2,768
  • 8
  • 9
  • jQuery doesn't care about the "." in find, and adding the "." did not help me. Whenever I log the text, it logs nothing (with the blue 66 next to it, because there are 66 different elements with the class upon the first load for me) – AlreadyPro Aug 12 '17 at 18:10
  • @AlreadyPro: jQuery uses and builds upon the Selectors API that is used both for CSS and JS selector engines, so jQuery certainly does need the `.` when performing selection based on class name. – spanky Aug 12 '17 at 18:11
  • There's not enough info in the question to know what else may be the problem. – spanky Aug 12 '17 at 18:12
  • Although that is true, it still didn't solve my question. – AlreadyPro Aug 12 '17 at 18:14
  • @AlreadyPro: Unfortunately we can't solve problems that we can't see. You'll need to provide a complete example and a description of the results of the debugging you've already performed. – spanky Aug 12 '17 at 18:22