this jsFiddle의 출력을 이해하려고합니다.왜 이러한 JavaScript 함수는 정의되지 않습니까?
왼쪽에있는 "외부 리소스"옵션을 사용하여 Google's CDN을 통해 jQuery UI를로드하고 있습니다.
어떤 것들은 ...
jQuery를 부분적으로 UI 일을 저를 당혹 게한다. "drag me"div를 드래그 할 수 있습니다.
그래서 jQuery UI
.draggable()
(docs)이 좋습니다. ()은 jQuery UI 테마 CSS를 적용하지 않습니다..draggable()
은 작동하지만.button()
이 아닌 이유는 무엇입니까? (구문 오류?)draggable
은undefined
일 수 있습니까?작동하므로 제대로 작동해야합니다.
click
은undefined
이 될 수 있습니까?click()
은 jQuery에서 가져온 것이고$
은 함수입니다.click
도 하나가 아니겠습니까?
여기에 내가 갖는 출력은
(function() {
$(document).ready(function() {
$('.dr').draggable();
$('.btn').button();
$('.btn').click(function(event) {
alert('Clicked');
});
$('.output').append('typeof $: ' + typeof $ + '<br />');
$('.output').append('typeof draggable: ' + typeof draggable + '<br />');
$('.output').append('typeof click: ' + typeof click + '<br />');
$('.output').append('typeof button: ' + typeof button + '<br />');
});
}());
... JS의
typeof $: function // As expected.
typeof draggable: undefined // How can it be undefined and still work?
typeof click: undefined // ???
typeof button: undefined
왜'$ ('...') .draggable'가'draggable'로 참조 될 수 있다고 가정합니까? JavaScript가 작동하는 방식이 아닙니다. – Xufox