您能告诉我开发人员如何在控制台上检查很多事情,同时在控制台上编写一些代码并按Enter。
我也开始做,但未能实现目标。
首先,我对小提琴进行按钮
<button id="test">test</button>
。
write these instruction on console.
$('#test')
null
$('#test').click(function(){)
SyntaxError: Unexpected token )
$('#test').click(function(){alert('---')})
TypeError: Cannot call method 'click' of null
event.returnValue is deprecated. Please use the standard event.preventDefault() instead. jquery-1.9.1.js:3345
$('#test').click(function(){alert('---')})
TypeError: Cannot call method 'click' of null
正如Mitch已经提到的那样,jQuery没有加载到jsFiddle上。因此,您将无法在Developer工具中使用jQuery。
您面临的另一个问题是您的输出窗口包含在iFrame中。不仅如此,它是一个带来安全问题的不同领域。即使已加载jQuery,如果尝试访问$('#test')
,也会看到类似以下错误:
SecurityError: Failed to read the 'contentDocument' property from
'HTMLIFrameElement': Blocked a frame with origin "http://jsfiddle.net" from
accessing a cross-origin frame.
那么,我们该如何解决呢?打开开发人员工具时,您需要执行以下操作:
1)在开发人员工具中,键入以下内容: document.getElementsByTagName('iframe')[0].src
这会将URL(类似:“ http://fiddle.jshell.net/MYA32/show/ ”)返回到您的小提琴页面。如果没有看到,则表示您没有保存小提琴。
2)在新窗口中打开该URL。
这是一个包含jQuery的jsfiddle。您现在应该可以使用jQuery!http://fiddle.jshell.net/MYA32/show/
顺便说一句,您可能会注意到,所有iFrame URL的格式都是相同的(只是fiddle.jshell.net和显示更改之间的内容。这将有助于您在将来快速打开输出。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句