为什么未定义此功能? [英] Why is this function undefined?
本文介绍了为什么未定义此功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望我已经过去了...但是为什么在单击按钮时未确定调整大小?
I was hoping i was past this... but why is is resize undefined on Button click?
$(document).ready(function(){
var w = [320, 480];
var h = [480, 620];
function resize (input){
$("scale").width(w[input]);
$("scale").height(h[input]);
}
$.each(w, function(i, val){
$("<button onclick='resize("+i+")'>"+val+"</button>").appendTo("body");
});
});
推荐答案
因为它位于document.ready函数中.
Because its inside the document.ready function.
您需要在全局级别具有resize功能,DOM才能看到它.
You need to have the resize function at the global level for the DOM to see it.
但是,更好的方法是使用jQuery的"on"功能.
However a better way of doing it would be to use the jQuery "on" function.
这篇关于为什么未定义此功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文