Javascript表单特效之十大常用原理性样例代码大总(6)

<!DOCTYPE html> <html> <head> <title></title> <meta charset="utf-8" /> </head> <body> <div> </div> <input type="text"/> <input type="button" value="添加" /> </div> <div> <ul> <li>红烧肉</li> <li>红烧肘子</li> <li>红烧鱼</li> </ul> </div> <script> var inp_aa = document.getElementsByClassName('aa'); inp_aa[0].value = '红烧带鱼';//相当于在输入框输入内容 </script> </body> </html>

<!DOCTYPE html> <html> <head> <title></title> <meta charset="utf-8" /> </head> <body> <div> </div> <input type="text"/> <input type="button" value="添加" /> </div> <div> <ul> <li>红烧肉</li> <li>红烧肘子</li> <li>红烧鱼</li> </ul> </div> <script> var c = document.querySelector('.aa');//查询选择器 .是区别id,标签的语法​ c.value = '红烧茄子'; </script> </body> </html>

方法二:查询

<!DOCTYPE html> <html> <head> <title></title> <meta charset="utf-8" /> </head> <body> <div> </div> <input type="text"/> <input type="button" value="添加" /> </div> <div> <ul> <li>红烧肉</li> <li>红烧肘子</li> <li>红烧鱼</li> </ul> </div> <script> var c = document.getElementById('aa');​ c.value = '红烧茄子'; </script> </body> </html>

方法三:id

案例六:

Javascript表单特效之十大常用原理性样例代码大总

//'beforeBegin'、'afterBegin'\ 'beforeEnd'\'afterEnd'

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wzswfs.html