jquery中设置Prototype为什么报错啊?jquery网站上是这样做的
var form = $("#myform");
form.prototype.clearForm = function() {
return this.find(":input").each(function() {
this.value = "";
}).end();
};
form.clearForm() // works for all instances of jQuery objects, because the new method was added to the prototype
firebug提示:
form.prototype is undefined
html代码:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">
New Document
<br> $(document).ready(function(){<br> var form = $("#myform");<br> form.prototype.clearForm = function() {<br> return this.find(":input").each(function() {<br> this.value = "";<br> }).end();<br> };<br> form.clearForm()<br> });<br>