微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

jQuery

 

 

script>
//原生js,选择器少,麻烦不好记
//标签
document.getElementsByTagName();
//id
document.getElementById();
//类
document.getElementsByClassName();

//jQuery css中的选择器它全部能用
$('p').click();//标签选择器
$('#id1').click();//id选择器
$('.class1').click();//class选择器

</script>
文档工具地址
.class | jQuery API 3.2 中文文档 | jQuery API 在线手册 (cuishifeng.cn)
事件

 


 

操作DOM
  <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
</head>
<body>

<ul id="test-ul">
<li class="js">javascript</li>
<li name="python">Python</li>
</ul>
<script>
$('#test-ul li[name=python]').text();
$('#test-ul li[name=python]').text('html');
$('#test-ul li[name=python]').html('<strong>123</strong>');
</script>
</body>

//css的操作
$('#test-ul li[class=js]').css({'color':'blue'})

//元素的显示和隐藏 本质:display:none
$('#test-ul li[class=js]').hide()//隐藏
$('#test-ul li[name=python]').show()
 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐