[英]Changing jQuery function to page load
誰能告訴我如何將以下當前由單選按鈕控制的語句更改為文檔加載功能。
基本上,我希望幻燈片div在頁面加載時從左向右滑動。 jQuery的:
jQuery(function() {
jQuery('#slide').hide();
jQuery(':radio[name=radiobutton]').click(function() {
var value = $(this).val();
if (value === 'Y') {
jQuery('#slide').show('slow');
} else if (value === 'N') {
jQuery('#slide').hide('slow');
}
});
HTML:
<div id="slide" class="alpha60">
<p class="statement_style_head">Content goes here</p>
<p class="statement_style_text">A line or two of text goes here </p>
</div>
$(document).ready({。Your staff。});
一種方法是像加載$('input[name=radiobutton]').click();
一樣在加載時單擊它$('input[name=radiobutton]').click();
或$('input[name=radiobutton]').trigger('click');
另一種方法是將您的代碼放在函數內,並在加載時調用該函數。
function showSomething(){
// code here
}
showSomething();
Document.ready是javascript的一種onload,它會等到一切就緒后再執行...您的代碼,這是onload的安全和最佳實踐
$(document).ready(function() {
$("divid").animate({top:'10px', bottom:0}, 3000);
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.