亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

jquery li標簽取值賦值問題

jquery li標簽取值賦值問題

函數式編程 2019-04-21 20:15:25
你說什么呢你說什么呢你說什么呢你說什么呢你說什么我希望實現的效果是,點擊class為question_keyword下的每個li標簽,會將點擊的這個li標簽中的text()傳給class為question_answer下的li標簽。同時如果傳入的text()數量超過了class為question_answer下的li標簽數量,程序會提示不能點擊。請問該如何寫jquery才是最簡便的呢?我網上查詢好像是需要給li標簽設置attr屬性。是不是太麻煩了。。
查看完整描述

2 回答

?
慕的地8271018

TA貢獻1796條經驗 獲得超4個贊

寫的不是很好,但是姑且可以用
$(document).ready(function(){
functionAnswer(curr,num,ele){
this.curr=curr;
this.num=num;
this.ele=ele;
}
Answer.prototype.getKeyword=function(){
varkeywordItems=$(".question_keyword>ul>li");
varanswer;
varthat=this;
keywordItems.on("click",function(){
if(that.curranswer=$(that.ele).eq(that.curr);
vartext=$(this).text();
answer.text(text);
that.curr=that.curr+1;
console.log(that.curr);
}else{
alert("超出限制啦");
}
});
};
varanswer=newAnswer(0,5,".question_answer>ul>li");
answer.getKeyword();
});
                            
查看完整回答
反對 回復 2019-04-21
  • 2 回答
  • 0 關注
  • 370 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號