在用戶登錄時無法擴展具有內容的div,而不需要任何click
函數來擴展div
,文檔加載時應該自動擴展它。使用jQuery
animate
方法,但我無法做到這一點
$(function(){
$("#wish_card").animate({
height: "200px"
});
});
在用戶登錄時無法擴展具有內容的div,而不需要任何click
函數來擴展div
,文檔加載時應該自動擴展它。使用jQuery
animate
方法,但我無法做到這一點
$(function(){
$("#wish_card").animate({
height: "200px"
});
});
您需要使用jQuery
提供$(document).ready()
方法。無論何時頁面被加載,這將啓動animate
方法。
$(document).ready(function(){
$("#wish_card").animate({
height: "200px"
});
});
演示:JsBin
$(window).load(function() {
$("#wish_card").animate({ height: "200px" });
});
雖然這可能會回答這個問題,但請提供任何解釋,以確保人們瞭解此處發生的情況。 – Randy
非常感謝這個建議,我會在回答時記住 –
可能,這將是非常有用的給你
我們通常使用
$("document").ready(function() {
// The DOM is ready!
// The rest of the code goes here
});
而且較短的版本是
$(function() {
// The DOM is ready!
// The rest of the code goes here
});
,這是最後的最佳實踐
(function($, window, document) {
// The $ is now locally scoped
// Listen for the jQuery ready event on the document
$(function() {
// The DOM is ready!
});
// The rest of the code goes here!
}(window.jQuery, window, document));
// The global jQuery object is passed as a parameter
小提琴的鏈接似乎不起作用。 –
@SomenathSinha鏈接已更新。 – Princess
你綁定在頁面加載的數據?你也可以使用window.load函數 –
YEs我綁定的數據,但真正的事情是,div應該在頁面加載後展開 –
在asp.net中?然後在數據綁定 –