顯示具有 jQuery 標籤的文章。 顯示所有文章
顯示具有 jQuery 標籤的文章。 顯示所有文章

$(window).scrollTop() vs. $(document).scrollTop()

2013年2月19日 星期二

筆記一下

They are both going to have the same effect.

Both scroll to the top of the object, an html document is considered the "document" thus scrolling to the top of the html page. A "window" object is created with each frame, thus your main window is one frame, if you had an "iframe" that would create another window object. So your just scrolling to the top of the window object, creating the same effect.

It seems that the window object is buggy when it comes to this. It apprently does not work in IE8 and Opera, so it is best to use $("html").scrollTop().

所以最好是用$("html").scrollTop().可支援多瀏覽器

 

 

 

 

資料來源:http://stackoverflow.com/questions/5371139/window-scrolltop-vs-document-scrolltop

Read more...

10個超好用的撰寫jQuery技巧

2012年8月30日 星期四

請參考


http://ithelp.ithome.com.tw/question/10021702

Read more...

jQuery.parseJSON問題

2012年7月5日 星期四

今天遇到一個問題,就是在ASP.NET後端產出json格式的資料,要在前端使用一直會出錯,查了一下發現,原來json格式外面要用單引號裡面的內容才是用雙引號,我把它反過來了,難怪會一直取不出來,以下為範例:


錯誤寫法
var obj = $.parseJSON("{'name':'neil'}");
alert(obj.name);
正確寫法
var obj = $.parseJSON('{"name":"neil"}');
alert(obj.name);

在javascript裡的宣告以下二種方式宣告都可以,不過在jQuery的JSON裡就不行囉,這點要注意啊

var name = "neil";
var name = 'neil';

Read more...