可以通过呢 jQuery 的 length 属性判断 id 是否存在:
也可以写成插件形式 如下 插件可以判断元素是否存在实例
$.fn.exists = function(callback) {var args = [].slice.call(arguments, 1);if (this.length) {callback.call(this, args);}return this;};// 使用方法$('div.test').exists(function() {this.append('
存在!
');});
尊贵的董事大人
英文标题不为空时 视为本栏投稿
需要关键字 描述 英文标题