.text(function(index,text)) 和 addClass(function(index,currentClass)) 的用法是不是不一樣?
慕課網(wǎng)說:
.text( function(index, text) ) 用來返回設(shè)置文本內(nèi)容的一個函數(shù)
.removeClass( function(index, class) ) : 一個函數(shù),返回一個或多個將要被移除的樣式名
描述差不多 但是w3shool說 “使用函數(shù)向被選元素添加類。”
addClass(function(index,class)) 究竟有沒有返回值,有這個返回值能調(diào)用嗎?
2017-09-07
addClass(function(index,class))的返回值是jQuery類型,返回當(dāng)前jQuery對象本身
addClass(function(index,class))里面的回調(diào)函數(shù)function(index,class)的返回值是要添加的css類名
類似的,
text( function(index, text) )的返回值是jQuery類型,返回當(dāng)前jQuery對象本身
text(function(index,class))里面的回調(diào)函數(shù)function(index,class)的返回值是文本內(nèi)容
還有,
removeClass( function(index, class) )?的返回值是jQuery類型,返回當(dāng)前jQuery對象本身
removeClass(function(index,class))里面的回調(diào)函數(shù)function(index,class)的返回值是要被移除的樣式名