12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>属性操作</title>
- </head>
- <body>
- <p>
- <a href="#">
- <apan>这是内容</apan>
- </a>
- </p>
- <input type="text" value="111111">
- <input type="text" value="222222">
- </body>
- <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
- <script>
- $(':text').eq(1).val('')
- // $('p').text('')
- // $('p').html('')
- // val(内容)
- // $(':text').eq(1).val('123456')
- // text(内容)
- // $('p').text('<strong>strong</strong>')
- // html(内容)
- // $('p').html('<strong>strong</strong>')
- // val() 只能用于表单组件
- // console.log($(':text').eq(1).val())
- // console.log($(':text').val())
- // text() 只能操作文本内容,不操作标签
- // console.log($('p').text())
- // html() 可以操作标签(文本里面如果还包含有标签,可以一并获取)
- // console.log($('p').html())
- </script>
- </html>
|