我有代码
$(function() {
// run the currently selected effect
function runEffect() {
// get effect type from
var selectedEffect = $( "#effectTypes" ).val();
// most effect types need no options passed by default
var options = {};
// some effects have required parameters
if ( selectedEffect === "scale" ) {
options = { percent: 100 };
} else if ( selectedEffect === "size" ) {
options = { to: { width: 280, height: 185 } };
}
// run the effect
$( "#effect" ).show( selectedEffect, options, 500, callback );
};
//callback function to bring a hidden box back
function callback() {
setTimeout(function() {
$( "#effect:visible" ).removeAttr( "style" ).fadeOut();
}, 1000 );
};
// set effect from select menu value
$( "#button" ).click(function() {
runEffect();
});
像dis,我想将dis的点击功能转换为加载功能,这是一个初学者,所以请帮助我
最佳答案
如果我理解正确,那么您想在页面加载时运行runEffect函数吗?
您可以通过在jQuery ready事件中调用函数来完成此操作。
// This is shorthand for $(document).ready(function() { ... })
$(function() {
// Declare the runEffect function here
runEffect();
});
关于javascript - 单击功能转换为加载功能,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23951073/