0

I got an error, if I try this:

var Box = $(window.parent.document).find("#box"); // works fine
var BoxContent = $(Box+" .bg > .content").text(); // error

console.log(BoxContent);

Error message ("Uncaught Error: Syntax error, unrecognized expression: [object Object] .bg .content")

What is my fail?

0

2 Answers 2

1

Box isn't a string, you can't meaningfully concatenate it with a string to create a new selector.

It's a jQuery object, so you can use .find() to search within it.

var BoxContent = Box.find(".bg > .content").text();
Sign up to request clarification or add additional context in comments.

Comments

1

try this one

var BoxContent = Box.find(".bg > .content").first().text();
// OR
var BoxContent = Box.find(".bg").first().find(".content").first().text();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.