为什么这个插件不起作用?Firebug没有发现任何错误.
(function ($) {
$.fn.clearForm = function () {
return this.each(function () {
$(this).on("focus", function () {
$(this).val() = '';
});
});
};
}(jQuery));
Run Code Online (Sandbox Code Playgroud)
并在HTML中
<script>
$(this).clearForm();
Run Code Online (Sandbox Code Playgroud)
谢谢!
使用 $(this).val('')instread $(this).val()='';
尝试这个
(function($) {
$.fn.clearForm = function (){
$(this).on("focus",function(){
$(this).val('');
});
};
}( jQuery ));
Run Code Online (Sandbox Code Playgroud)