用于判断页面元素是否存在: if ( $("#ID").length > 0 ) { $("#ID").text("hi"); } 转载于:https://www.cnblogs.com/mrnx2004/p/10905935.html