jquery操作内容
作者:互联网
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="node_modules/jquery/dist/jquery.min.js"></script> </head> <body> <div id="box"> <div> 1111111 <p> 2222222 <span>3333333</span> </p> </div> </div> <ul> </ul> <input type="text"> </body> </html> <script> // html() 获得dom结构 console.log($('#box').html()) // 添加 let arr = ['aaa','bbb','ccc'] let listr = arr.map(item=>`<li>${item}</li>`).join('') $('ul').html(listr) // text() 获得内容,不带 dom 结构 console.log($('#box').text()) // val() console.log($('input').val()) </script>
标签:jquery,arr,console,log,val,text,html,内容,操作 来源: https://www.cnblogs.com/qianlichanganjie/p/16663545.html