JQuery的功能,這可能是一個非常基本的問題,但我想知道這種行爲調用來自不同背景
這是我的javascript代碼。我想知道爲什麼第二次調用foo不起作用。這裏是JSFiddle link
$.fn.foo = function(somestring){
var $this = this;
$this.html(somestring);
}
$(function(){
$('#container').foo("within function"); //this works
});
$('#container').foo("outside"); //this does not
對不起,請您詳細說明 – sublime
@johnknaan ..查看帖子 –