谁能告诉我如何将当前由单选按钮控制的以下语句更改为文档加载函数。
基本上,我希望当页面加载时,幻灯片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>
发布于 2010-12-04 03:44:05
$(文档).ready({.你的员工。});
发布于 2010-12-04 03:47:11
一种方法是在加载时单击它,如$('input[name=radiobutton]').click();
或$('input[name=radiobutton]').trigger('click');
另一种方法是将您的代码放在一个函数中,并在加载时调用该函数。
function showSomething(){
// code here
}
showSomething();
发布于 2010-12-04 03:47:16
对于javascript,Document.ready是一种onload,它等待一切准备就绪,然后executes...your代码,它是onload的安全和最佳实践。
$(document).ready(function() {
$("divid").animate({top:'10px', bottom:0}, 3000);
});
https://stackoverflow.com/questions/4349274
复制相似问题