jQuery
来源:互联网 发布:淘宝申请天猫客服介入 编辑:程序博客网 时间:2024/06/06 02:19
text():获取匹配元素集合中每个元素的组合文本内容,包括其后代。
<!doctype html><html lang="en"><head> <meta charset="utf-8"> <title>text demo</title> <style> p { color: blue; margin: 8px; } b { color: red; } </style> <script src="https://code.jquery.com/jquery-1.10.2.js"></script></head><body><p><b>Test</b> Paragraph.</p><p></p><script>var str = $( "p:first" ).text();$( "p:last" ).html( str );</script></body></html>
html():获取匹配元素集合中第一个元素的HTML内容。
<!doctype html><html lang="en"><head> <meta charset="utf-8"> <title>html demo</title> <style> p { margin: 8px; font-size: 20px; color: blue; cursor: pointer; } b { text-decoration: underline; } button { cursor: pointer; } </style> <script src="https://code.jquery.com/jquery-1.10.2.js"></script></head><body><p> <b>Click</b> to change the <span id="tag">html</span></p><p> to a <span id="text">text</span> node.</p><p> This <button name="nada">button</button> does nothing.</p><script>$( "p" ).click(function() { var htmlString = $( this ).html(); $( this ).text( htmlString );});</script></body></html>
Val():获取匹配元素集合中第一个元素的当前值。
<!doctype html><html lang="en"><head> <meta charset="utf-8"> <title>val demo</title> <style> p { color: red; margin: 4px; } b { color: blue; } </style> <script src="https://code.jquery.com/jquery-1.10.2.js"></script></head><body><p></p><select id="single"> <option>Single</option> <option>Single2</option></select><select id="multiple" multiple="multiple"> <option selected="selected">Multiple</option> <option>Multiple2</option> <option selected="selected">Multiple3</option></select><script>function displayVals() { var singleValues = $( "#single" ).val(); var multipleValues = $( "#multiple" ).val() || []; // When using jQuery 3: // var multipleValues = $( "#multiple" ).val(); $( "p" ).html( "<b>Single:</b> " + singleValues + " <b>Multiple:</b> " + multipleValues.join( ", " ) );}$( "select" ).change( displayVals );displayVals();</script></body></html>
<!doctype html><html lang="en"><head> <meta charset="utf-8"> <title>val demo</title> <style> p { color: blue; margin: 8px; } </style> <script src="https://code.jquery.com/jquery-1.10.2.js"></script></head><body><input type="text" value="some text"><p></p><script>$( "input" ) .keyup(function() { var value = $( this ).val(); $( "p" ).text( value ); }) .keyup();</script></body></html>
阅读全文
0 0
- JQuery
- JQuery
- JQuery
- JQuery
- JQuery
- JQuery
- JQuery
- JQuery
- JQuery
- JQuery
- JQuery
- JQuery
- JQuery
- JQUERY
- jquery
- jQuery
- jquery
- jquery
- 简单说说angularJS和一个经典例子
- 在centos7系统环境下安装nodejs
- libjpeg转换
- C# using 解析
- 纯js模拟下拉框
- jQuery
- 存储
- 【区块链】搭建基于ethereum以太坊环境的私有链
- flume监控
- linux关于防火墙的相关操作
- JavaScript JSON
- 使用YYModel转模型
- vmware12 无权输入验证码
- Kali linux更新后登录界面无限循环问题解决