jq获取当前li里的属性值_十.JQ操作DOM

1d802a6645f2f03f9028fa9a7bb86dec.png

1.获取ID为"id"的标签: document.getElementById("id")

2.获取所有name为"name"的标签: document.getElementsByName("name")

3.获取所有类名为"class"的标签: document.getElementsByClassName("class")

4.样式操作

a.$(this).css("name","value") // 单独一个样式操作

b.$(this).css({"name":"value","name":"value",……}) // 多个样式操作

c.添加类: $(this).addClass("class") // 可以同时操作多个类,以空格分隔

d.删除类: $(this).removeClass("class") // 可以同时操作多个类,以空格分隔

e.判断为指定样式: $(this).hsaClass("class")

f.添加和删除类之间的切换: toggleClass(".class")

5.内容操作

a.$(this).text() // 设置当前标签的文本值

$(this).text() // 不带参数时获取当前元素的文本值

$(this).text("content") // 设置前元素的文本值为content

$(this).text(function(index,value){retuen ""}) // "index,value"都是可选,当只存在一个时,"value"则会省略,利用return返回

"index": 接受当前元素的"index"位置

"value": 接受当前元素的文本值

b.$(this).html("") // 设置当前标签的文本值及HTML内容

$(this).html() // 不带参数时获取当前元素的文本值及HTML内容

$(this).html("content") // 设置前元素的文本及HTML内容为content

$(this).html(function(index,value){retuen ""}) // "index,value"都是可选,当只存在一个时,"value"则会省略,利用return返回

"index": 接受当前元素的"index"位置

"value": 接受当前元素的文本及HTML内容

c.$(this).val() 设置当前标签的value属性值

$(this).val() // 不带参数时获取当前元素的"value"值

$(this).val("content") // 设置当前元素的"value"值为content

$(this).val(function(index,value){retuen ""}) // "index,value"都是可选,当只存在一个时,"value"则会省略,利用return返回

"index": 接受当前元素的"index"位置

"value": 接受当前元素的"value"属性值

6.设置属性: $(this).attr()

a.$(this).attr("name") // 获取当前属性的name值

b.$(this).attr("name","value") // 设置当前属性name值为value

c.$(this).attr({"name":"value","name":"value"……}) // 设置当前多个属性值

7.删除属性: $(this).removeAttr("name") // 可以同时删除多个属性,用空格分隔

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
import tushare as ts import datetime # 设置 token,用于认证 ts.set_token('530fbc2b682d65696dbeec010a893f70d6953fbb6842151003c3e12f') # 初始化 tushare pro = ts.pro_api() df = pro.daily(fields = 'ts_code,trade_date,open,close',start_date='20180701', end_date='20180718') def get_stock_poll(df): stock_pool=[] for code in df['ts_code'].unique(): temp_df = df[df['ts_code'] == code ] for i in range(len(temp_df)-3): if (temp_df.iloc[i + 3]['close'] > temp_df.iloc[i + 2]['close']) and \ (temp_df.iloc[i + 2]['close'] > temp_df.iloc[i + 2]['open']) and \ (temp_df.iloc[i + 1]['close'] > temp_df.iloc[i + 1]['open']) and \ (temp_df.iloc[i]['close'] > temp_df.iloc[i]['open'])and \ (temp_df.iloc[i + 3]['close'] > temp_df.iloc[i + 2]['close'])and \ (temp_df.iloc[i + 2]['close'] > temp_df.iloc[i + 1]['close']) and\ (temp_df.iloc[i + 1]['close'] > temp_df.iloc[i]['close']): stock_pool.append(code) break return stock_pool def buy_stock(stock_pool,df): buy_list = [] for code in stock_pool: temp_df = df[df['ts_code']==code] for i in range(len(temp_df-2)): if(temp_df.iloc[i + 2]['close'] < temp_df.iloc[i + 2]['open']) and \ (temp_df.iloc[i + 1]['close'] < temp_df.iloc[i + 1]['open']) and \ (temp_df.iloc[i]['close'] < temp_df.iloc[i]['open'])and \ (temp_df.iloc[i + 2]['close'] < temp_df.iloc[i + 1]['close'])and \ (temp_df.iloc[i + 1]['close'] < temp_df.iloc[i]['close']): buy_list.append(code) break return buy_list def sell_stock(buy_stock,df): sell_list = [] for stock in buy_list: buy_date=dateime.datetime.strptime(stock[1],"%Y-%m-%d") current_date = datetime.datetime.today() days_held = (current_date - buy_date).days if days_held >=3: sell_list.append(stock[0]) print("sell list:",sell_list)要求上述代码在聚宽上运行
最新发布
06-01

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值