Discuz! Board

 找回密碼
 立即註冊
搜索
熱搜: 活動 交友 discuz
查看: 5|回復: 0
打印 上一主題 下一主題

unfold menu using JavaScript, consider the case where JS does not work

[複製鏈接]

1

主題

1

帖子

5

積分

新手上路

Rank: 1

積分
5
跳轉到指定樓層
樓主
發表於 2024-2-20 11:56:41 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
When you click on the parent menu of a group, the hidden child menus of that parent appear in a row. This is a so-called foldable menu. It also has the benefit of reducing page transitions for users, so it can be said that it is a UI with good usability. However, these days, JavaScript works in most environments, and we often see cases where we are not prepared for cases where JavaScript does not work. Also, if you say so, it is often not very good from an SEO perspective. If you use JavaScript to add extra benefits, you should be able to use it without any problems even if JS doesn't work in the first place, and being careful in that aspect will also have a positive effect on SEO. This column includes SEO, but it's more about usability.


Accordion Menu Basics How to create an environment where JS is disabled Canada Phone Number Data Accordion Menu Basics First of all, as a premise before renovation, I will introduce the basic method of making it. It's a foldable menu developed using JS, but it's relatively easy to create, and the rough explanation is as follows. Prepare HTML with parent-child structure Child menus are initially hidden When clicking the parent menu, show/hide the child menu using JS "HTML with a parent-child structure" generally means nesting ul/li tags. Also, I sometimes see dl tags used like ``parent is dt tag'' and ``child is dd tag''. The key is to understand the relationship between parents and children as a document structure.




How to create an environment where JS is disabled Now, the accordion menu is a UI using JavaScript. Since it uses JavaScript, it will naturally not become an accordion menu in an environment where JavaScript does not work. If you use JavaScript, you should either make it work even if JS doesn't work, or provide alternative content (or a message like "Please turn on JS"). This is the so-called noscript philosophy. The following are points to keep in mind when creating a website, taking into account that JavaScript may not work in some cases. Also write the link URL (href attribute) in the a tag of the parent menu. Display the child menu at first, then hide it when JS is running If there are many child menus, do not write them in the HTML, but add them to the DOM later using JS. We will briefly explain the reasons and benefits for each. Also write the link URL (href attribute) in the a tag of the parent menu.


回復

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 立即註冊

本版積分規則

Archiver|手機版|自動贊助|GameHost抗攻擊論壇  

GMT+8, 2025-3-4 22:15 , Processed in 0.204698 second(s), 5 queries , File On.

抗攻擊 by GameHost X3.3

© 2001-2017 Comsenz Inc.

快速回復 返回頂部 返回列表
一粒米 | 中興米 | 論壇美工 | 設計 抗ddos | 天堂私服 | ddos | ddos | 防ddos | 防禦ddos | 防ddos主機 | 天堂美工 | 設計 防ddos主機 | 抗ddos主機 | 抗ddos | 抗ddos主機 | 抗攻擊論壇 | 天堂自動贊助 | 免費論壇 | 天堂私服 | 天堂123 | 台南清潔 | 天堂 | 天堂私服 | 免費論壇申請 | 抗ddos | 虛擬主機 | 實體主機 | vps | 網域註冊 | 抗攻擊遊戲主機 | ddos |