How come I cannot make $(frame) a jQuery object in the below case? Below is my output from chrome developer tools.
console: mainFrame
output: <frame src="http://someurl" name="mainFrame">
console: $(mainFrame).contents()
output: SyntaxError: Failed to execute 'querySelector' on 'Document': '[object HTMLFrameElement]' is not a valid selector.
Edit:
to respond to comments...
$.toString()
"function $(selector, [startNode]) { [Command Line API] }"
typeof(mainFrame)
"object"
jQuery
ReferenceError: jQuery is not defined
How come I cannot make $(frame) a jQuery object in the below case? Below is my output from chrome developer tools.
console: mainFrame
output: <frame src="http://someurl.com" name="mainFrame">
console: $(mainFrame).contents()
output: SyntaxError: Failed to execute 'querySelector' on 'Document': '[object HTMLFrameElement]' is not a valid selector.
Edit:
to respond to comments...
$.toString()
"function $(selector, [startNode]) { [Command Line API] }"
typeof(mainFrame)
"object"
jQuery
ReferenceError: jQuery is not defined
Share
Improve this question
edited Mar 19, 2014 at 14:01
Maximus S
asked Mar 19, 2014 at 11:52
Maximus SMaximus S
11.1k19 gold badges80 silver badges163 bronze badges
6
|
Show 1 more comment
3 Answers
Reset to default 16jQuery doesn't seem to be included in your document. Some browsers set $
to querySelector
by default (which is a native way to select elements of the DOM using css-like syntax), thereby your error message. Try adding
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
Looks like jQuery is not included into the DOM, try to include jQuery either by CDN or add standalone jQuery into the DOM.
You can confirm the jQuery installation by typing $
into the browser inspect tab.
If the output is something like
> $
ƒ (e,t){return new x.fn.init(e,t,r)}
then jQuery added successfully.
Try
$(frame).contents();
Or
$("html", frame);
not sure which one will work.
$.toString()
andtypeof mainFrame
? – plalx Commented Mar 19, 2014 at 11:58$
is jQuery here, tryjQuery(mainFrame).contents()
– Musa Commented Mar 19, 2014 at 12:26