$(function() { var store = { money1: '', jg: '', init: function() { this.gupiao(); }, gupiao() { let that = this; $.ajax({ url: "https://qt.gtimg.cn/q=sz002768", type: "get", success: function(res) { var elements = res.split("~"); console.log(elements); that.money1 = elements[9];//今日股票 that.jg = elements[31];//涨幅 that.even(); }, }); }, even() { let that = this; $('#c_static_001-1700191228447 .e_text-27').text(that.money1); console.log('that.jg',that.jg); if(that.jg>0){ $('#c_static_001-1700191228447 .e_text-27').addclass('jia') }else{ $('#c_static_001-1700191228447 .e_text-27').addclass('jian') } }, } store.init(); })