HTML与CSS练习——js选择器
来源:互联网 发布:面包板入门单片机 编辑:程序博客网 时间:2024/06/07 04:53
<div class="slider_page_item">
<div class="slider_page_title">
<a href="#">Preserve agricultural diversity</a>
</div>
<div class="slider_page_text playno">
<p>Organically grown foods have more nutrients—vitamins, minerals, enzymes, and micronutrients—than commercially grown foods because the soil is managed and nourished with sustainable practices by responsible standards. Organic farming supports eco-sustenance, or farming in harmony with nature.</p>
</div>
</div>
<script type="text/javascript">
var slider_page_title = $('.slider_page_title');
slider_page_title.on('click', function() {
$(this).toggleClass("active");
});
var slider_page_item = $('.slider_page_item');
var slider_page_text = $('.slider_page_text');
slider_page_title.on('click',function(){
if ($(this).is('.active')) {
// 等同于 $(this).parent().find('.slider_page_text').removeClass("playno");
$(this).siblings('.slider_page_text').removeClass("playno");
}else{
$(this).parent().find('.slider_page_text').addClass("playno");
};
});
<div class="slider_page_title">
<a href="#">Preserve agricultural diversity</a>
</div>
<div class="slider_page_text playno">
<p>Organically grown foods have more nutrients—vitamins, minerals, enzymes, and micronutrients—than commercially grown foods because the soil is managed and nourished with sustainable practices by responsible standards. Organic farming supports eco-sustenance, or farming in harmony with nature.</p>
</div>
</div>
<script type="text/javascript">
var slider_page_title = $('.slider_page_title');
slider_page_title.on('click', function() {
$(this).toggleClass("active");
});
var slider_page_item = $('.slider_page_item');
var slider_page_text = $('.slider_page_text');
slider_page_title.on('click',function(){
if ($(this).is('.active')) {
// 等同于 $(this).parent().find('.slider_page_text').removeClass("playno");
$(this).siblings('.slider_page_text').removeClass("playno");
}else{
$(this).parent().find('.slider_page_text').addClass("playno");
};
});
</script>
实现单个点击显示隐藏效果
阅读全文
0 0
- HTML与CSS练习——js选择器
- HTML巩固练习之CSS选择器基础
- HTML&CSS——nth-child()选择器
- 重回JS—简单选择器(练习)
- HTML与CSS练习总结
- 2016 08 10 css选择器练习——常用属性
- js笔记:Js封装库——css选择器
- css选择器的练习
- fgm实例练习笔记-1.5js写css hover选择器
- Html+Css详解Css选择器,优先级与匹配原理
- Html+CSS中子选择器
- HTML/CSS选择器
- CSS基础(一)--选择器与权重计算练习
- CSS——选择器
- CSS——选择器
- Html+CSS CSS中的选择器
- CSS—组合选择器
- CSS—选择器
- Spark 之 一些常用的操作
- 中企动力全面赋能中小企业 让大数据场景化营销落地生花
- CUDA6.5+VS2010安装和搭建过程
- 8086CPU端口读写
- webrtc libjingle worker thread
- HTML与CSS练习——js选择器
- 安卓学习-(数据存储(数据库,原生sql,和原生安卓操作))
- spring_定时任务_spring-task_定时输出
- C语言实现2048小游戏
- 欢迎使用CSDN-markdown编辑器
- USB 中MTP和UMS 模式
- Android Studio 的 gradle 错误
- Android NDK操作
- 参数名称 'LevenbergMarquardt' 无法识别。请参阅文档中的 optimset 参考页