toggle

前端系统设计

大兔子大兔子 提交于 2020-01-17 08:30:14
前端系统设计 前端三大件:html、css、js,万变不离其中,不管我们使用的是vue、react、angular还是其他什么,都是要提高我们代码的复用性、可读性、可维护性以及可拓展性。 html 语义化的标签,在不借助任何前端框架的情况下, < header > < section > < nav > < ul > < li > < a href = " # " > 菜单1 </ a > </ li > < li > < a href = " # " > 菜单2 </ a > </ li > </ ul > </ nav > </ section > </ header > 这种方式能有一定的可读性,但在更为复杂的页面的结构之下是不是缺失了可读性和可维护性。 组件化控制html结构,运用组件化架构的方式将一个页面划分为多个组件,包括项目级组件(在整个范围都会使用到的)和页面级组件 组件化的优势点: 提高复用性 举例:按钮组件,整个系统的按钮风格应该大致差不错,拥有的行为也差不多。我们将按钮单独抽离出来作为一个单独的组件,它拥有自己独立的结构、样式、行为,遵从单一职责、开闭原则,当我们在构建下一个页面的时候,直接引入既可以使用,达到了提高复用性的效果。 提高可读性 举例:我们一个页面有很多的内容,以上图来看,我们这个页面的结构大致是,头部,导航栏,搜索框,按钮组

How to show an ul when a particular li is clicked using jquery?

一个人想着一个人 提交于 2020-01-17 06:08:30
问题 I want to show the ul class of li which is clicked. My html is: <ul id="level1" class="category"> <li class="level1 inactive"> <a href="#">abc</a> <ul id="level2" style=" display:none;"> <li class="level2 inactive"><a href="#">Level2</a></li> <li class="level2 inactive"><a href="#">Level2</a></li> <li class="level2 inactive"><a href="#">Level2</a></li> </ul> </li> <li class="level1 inactive"> <a href="#">xyz</a> <ul id="level2" style=" display:none;"> <li class="level2 inactive"><a href="#"

How to show an ul when a particular li is clicked using jquery?

我与影子孤独终老i 提交于 2020-01-17 06:07:06
问题 I want to show the ul class of li which is clicked. My html is: <ul id="level1" class="category"> <li class="level1 inactive"> <a href="#">abc</a> <ul id="level2" style=" display:none;"> <li class="level2 inactive"><a href="#">Level2</a></li> <li class="level2 inactive"><a href="#">Level2</a></li> <li class="level2 inactive"><a href="#">Level2</a></li> </ul> </li> <li class="level1 inactive"> <a href="#">xyz</a> <ul id="level2" style=" display:none;"> <li class="level2 inactive"><a href="#"

Javascript toggle between three hidden divs

China☆狼群 提交于 2020-01-17 06:05:11
问题 Hey all, Newbie here, so please forgive my approach and specifics. I'd appreciate some help! I'm working on an image gallery that's got three sections, of which only one will be visible at a time. At the top of the page there are three links that I want to toggle one of the three sections to show while hiding the other two. The code I've written is poor and works only from Link 1 to Link 2 to Link 3, but not backwards or from link 1 to 3, 3 to 1, etc. Thanks for your help and advice! HTML:

Javascript toggle between three hidden divs

☆樱花仙子☆ 提交于 2020-01-17 06:04:04
问题 Hey all, Newbie here, so please forgive my approach and specifics. I'd appreciate some help! I'm working on an image gallery that's got three sections, of which only one will be visible at a time. At the top of the page there are three links that I want to toggle one of the three sections to show while hiding the other two. The code I've written is poor and works only from Link 1 to Link 2 to Link 3, but not backwards or from link 1 to 3, 3 to 1, etc. Thanks for your help and advice! HTML:

Arduino Switch to Turn a Relay timer

∥☆過路亽.° 提交于 2020-01-17 05:07:36
问题 Briefly: I would like to turn on a relay for 30 seconds, after I toggle a switch on. I'm trying to do a blinds automation at home. I have a simple ON-OFF-ON switch, attached to an Arduino connected to Relays. I want to turn on Relay#1 for a maximum of 30 seconds if I toggle the switch down from center. In other words, relay turns on when I switch, and when timer reaches 30 seconds relay turns off. similarly I want to turn on Relay#2 for exactly 30 seconds if I toggle the switch up from center

Enable disable fixed column in DataTable using a button

不羁的心 提交于 2020-01-17 02:58:25
问题 Myself created a html table with fixed columns using jquery DataTable with reference to This example as, $(document).ready(function() { var table = $('#example').DataTable( { scrollY: "300px", scrollX: true, scrollCollapse: true, paging: false } ); new $.fn.dataTable.FixedColumns( table, { leftColumns: 2 } ); } ); UPDATE: Myself trying to enable/disable the fixed column using a button as given in this fiddle as, var columnNumber = 2; $('#ToggleColumns').click(function () { if(columnNumber ==

hide all visible <ul> when parent <li> is clicked

最后都变了- 提交于 2020-01-17 01:21:14
问题 Good evening I've got a basic structure of ul, li and nested drop-down menus in the form of ul's. What I'm trying to do is that when the parent li is clicked, the child ul will show up. When the li is clicked again, the child ul hides. So this is what I've got so far $(document).ready(function() { $("ul#glass-buttons li").toggle(function() { $("ul", this).show(); }, function () { $("ul", this).hide(); }); }); It works perfectly, the only problem is that there are multiple child drop-down

jQuery dynamic underlining

萝らか妹 提交于 2020-01-16 08:50:34
问题 I've got hidden divs that my navigation menu shows/hides. When showing/hiding the divs, the corresponding menu option is underlined; meaning the former div fades out, the current div fades in, and the underline follows. The underline does not hide when you close a div by re-clicking on its name in the menu. So ideally the underline will dynamically be added/removed following the dynamic div toggling. Thanks for your time and patience! HTML: <div id="nav"> <a class="home" id="show_brand" title

Hide/show toggle separate divs with the same class name

試著忘記壹切 提交于 2020-01-15 10:39:33
问题 I've got a UL list, each LI has a hidden DIV, and a "More info" link that shows the hidden DIV. However, clicking this button shows all the other LI's hidden DIVs as well. How can I only hide/show the DIV in the LI, and not have all the other hidden DIV's show? And if I click on one how can I hide the others? I'd like to keep this part separate though in case I want to remove it later. Also on click I want the text in the "More info" link to change to "Hide". Here's my current script: $