This article mainly introduces the implementation method of context selector in JQuery, involving related skills of jQuery operating page elements. Friends in need can refer to it
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>上下文选择器</title> <script src="jquery-1.6.2.min.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { $("#btnTest").click( function () { //表示取得表单id为mf内的所有单行文本框 $(":text", $("#mf")).val("我是表单内的文本框"); } ); }); </script> </head> <body> <input type="text" /> <input type="text" /> <input type="button" id="btnTest" value="单击我改变表单内的文本框文本" /> <form id="mf" action="1.htm"> <input type="text" /> <input type="text" /> <input type="text" /> </form> </body> </html>
[Related tutorials recommended]
1. JavaScript video tutorial
2. JavaScript online manual
3. bootstrap tutorial