text() 方法方法设置或返回被选元素的文本内容。
1.设置被选元素的文本内容
$(selector).text(content);
例子: $('.tip em').text(title);
2.使用函数设置文本内容:$(selector).text(function(index,oldcontent))
参数:
- index - 可选。接受选择器的 index 位置。
- html - 可选。接受选择器的当前内容。
3.返回被选元素的文本内容:$(selector).text()
text() 方法方法设置或返回被选元素的文本内容。
1.设置被选元素的文本内容
$(selector).text(content);
例子: $('.tip em').text(title);
2.使用函数设置文本内容:$(selector).text(function(index,oldcontent))
参数:
3.返回被选元素的文本内容:$(selector).text()
转载于:https://www.cnblogs.com/itlichen/p/5944651.html