jquery text()
2013-12-16 13:36
281 查看
jquery text()
.text()
This method does not accept any arguments.
Unlike the .html() method, .text() can be used in both XML and HTML documents. The result of the .text() method is a string containing the combined text of all matched elements. (Due to variations in the HTML parsers in different browsers, the text returned
may vary in newlines and other white space.)
.text()获取标签里的文本内容,.html()会连同标签一起获取
The .text() method cannot be used on form inputs or scripts. To set or get the text value of input or textarea elements, use the .val() method. To get the value of a script element, use the .html() method.
As of jQuery 1.4, the .text() method returns the value of text and CDATA nodes as well as element nodes.
.text( textString )
Description: Set the content of each element in the set of matched elements to the specified text.
textString
Type: String
A string of text to set as the content of each matched element.
.text( function(index, text) )
function(index, text)
Type: Function()
A function returning the text content to set. Receives the index position of the element in the set and the old text value as arguments.
Unlike the .html() method, .text() can be used in both XML and HTML documents.
We need to be aware that this method escapes the string provided as necessary so that it will render correctly in HTML. To do so, it calls the DOM method .createTextNode(), does not interpret the string as HTML.
.text()
This method does not accept any arguments.
Unlike the .html() method, .text() can be used in both XML and HTML documents. The result of the .text() method is a string containing the combined text of all matched elements. (Due to variations in the HTML parsers in different browsers, the text returned
may vary in newlines and other white space.)
.text()获取标签里的文本内容,.html()会连同标签一起获取
The .text() method cannot be used on form inputs or scripts. To set or get the text value of input or textarea elements, use the .val() method. To get the value of a script element, use the .html() method.
As of jQuery 1.4, the .text() method returns the value of text and CDATA nodes as well as element nodes.
.text( textString )
Description: Set the content of each element in the set of matched elements to the specified text.
textString
Type: String
A string of text to set as the content of each matched element.
.text( function(index, text) )
function(index, text)
Type: Function()
A function returning the text content to set. Receives the index position of the element in the set and the old text value as arguments.
Unlike the .html() method, .text() can be used in both XML and HTML documents.
We need to be aware that this method escapes the string provided as necessary so that it will render correctly in HTML. To do so, it calls the DOM method .createTextNode(), does not interpret the string as HTML.
相关文章推荐
- 使用jquery构建Metro style 返回顶部
- 实现分页pagration的方法jquery(个人感觉用到了easyui貌似)
- Reveal Jquery 模式对话框插件
- jquery图片上下翻滚、图片左右翻滚、图片淡隐淡现3种图片滚动特效
- jQuery.Autocomplete实现自动完成功能(详解)
- jQuery文件下载插件 Downloadr
- jQuery:hasClass() 方法检查被选元素是否包含指定的 class;after()在某元素之后插入新元素
- 强烈推荐:240多个jQuery插件
- jQuery Mobile 入门基础教程
- 使用java的html解析器jsoup和jQuery实现一个自动重复抓取任意网站页面指定元素的web应用
- 带有查询和排序功能的jquery分页插件——DataTables
- 使用jQuery的9个误区
- Signs of a poorly written jQuery plugin 翻译 (Jquery插件开发注意事项,Jquey官方推荐)
- JQuery 限制文本框只能输入数字和小数点
- Jquery类级别与对象级别插件开发
- 快速开发 jQuery 插件的 10 大技巧(转)
- jquery中当text文本框为空时,button按钮是disabled状态,否则为enable状态
- jquery中当text文本框为空时,button按钮是disabled状态,否则为enable状态且输入框只能输入数字。并用alert显示第一个数字
- jquery中当text文本框为空时,button按钮是disabled状态,否则为enable状态且输入框只能输入数字。
- 深入理解jQuery插件开发(转)