HMTL arşivleri - Filika Creative https://ndr.ist/en/category/hmtl/ Web Tasarım, Sosyal Medya, Yazılım, Grafik, Video Tasarım Sun, 17 Apr 2022 09:17:38 +0000 en-US hourly 1 https://wordpress.org/?v=7.0 https://ndr.ist/wp-content/uploads/2018/04/cropped-logo-32x32.png HMTL arşivleri - Filika Creative https://ndr.ist/en/category/hmtl/ 32 32 Hide/show items based on expression in URL (can be index or variable) – with Javascript https://ndr.ist/en/hide-show-items-based-on-expression-in-url-can-be-index-or-variable-with-javascript/ https://ndr.ist/en/hide-show-items-based-on-expression-in-url-can-be-index-or-variable-with-javascript/#respond Sun, 17 Apr 2022 08:34:30 +0000 https://ndr.ist/?p=688 In this article I will describe how to hide and show html content with any ID based on an expression in the site URL. This code is built in javascript...

The post Hide/show items based on expression in URL (can be index or variable) – with Javascript appeared first on Filika Creative.

]]>
In this article I will describe how to hide and show html content with any ID based on an expression in the site URL.
This code is built in javascript so we expect it to work on almost all systems. Descriptions of this code are given below.

You can hide an item with the following code.

<script>
//In the URL containing HOME.COM/CATEGORY1/SUBCATEGORY1, the item with the ID HIDE-CONTENT will be hidden.
if (window.location.href.indexOf("/CATEGORY1/SUBCATEGORY1") != -1)
{ document.getElementById('HIDE-CONTENT').style.display = 'none'; };
>
</script>

You can show any element on pages with specified URL layout with below code. It will be hidden everywhere else. Before doing this, make sure you add the style style=”display:none” to the element. Thus, content that is already hidden will only be visible on certain pages.
<script>
//In the URL containing HOME.COM/CATEGORY/SUBCATEGORY the item with the id SHOW-CONTENT will be displayed.
//Assuming you saved this item as hidden before.
if (window.location.href.indexOf("HOME.COM/CATEGORY/SUBCATEGORY") != -1)
{ document.getElementById('SHOW-CONTENT').style.display = 'inline-block'; };
</script>

 

 

The post Hide/show items based on expression in URL (can be index or variable) – with Javascript appeared first on Filika Creative.

]]>
https://ndr.ist/en/hide-show-items-based-on-expression-in-url-can-be-index-or-variable-with-javascript/feed/ 0