This script works very well. But I want to show and hide different texts with different expand/hide links in the same multiple tables of the same page. Without JQuery this simple script is preferred. Thank you for your time and interest.
Show/hide Javascript Toggle in the same page problem. Multiple hidden texts shows up in the same time. Without JQuery
40 views Asked by Oguz Coskun At
2
There are 2 answers
0
Hedayat H
On
Look into this code i tried this without jQuery. if you will include jquery it will be too easy task.
function toggleme(elementId) {
var ele = document.getElementById(elementId);
if (ele.style.display === "block" || ele.style.display === "") {
ele.style.display = "none";
} else {
ele.style.display = "block";
}
}
body {
font-family: Arial, sans-serif;
}
a {
cursor: pointer;
color: blue;
text-decoration: underline;
margin-right: 10px;
}
.hideme {
padding: 10px;
border: 1px solid #ccc;
margin-top: 10px;
}
<a onclick="toggleme('toggleText1');">Show</a>
<div id="toggleText1" class="hideme" style="display: none">
<h1>Hello world 1</h1>
</div>
<a onclick="toggleme('toggleText2');">Show</a>
<div id="toggleText2" class="hideme" style="display: none">
<h1>Hello world 2</h1>
</div>
Related Questions in JAVASCRIPT
- Using Puppeteer to scrape a public API only when the data changes
- inline SVG text (js)
- An array of images and a for loop display the buttons. How to assign each button to open its own block by name?
- Storing the preferred font-size in localStorage
- Simple movie API request not showing up in the console log
- Authenticate Flask rest API
- Deploying sveltekit app with gunjs on vercel throws cannot find module './lib/text-encoding'
- How to request administrator rights?
- mp4 embedded videos within github pages website not loading
- Scrimba tutorial was working, suddenly stopped even trying the default
- In Datatables, start value resets to 0, when column sorting
- How do I link two models in mongoose?
- parameter values only being sent to certain columns in google sheet?
- Run main several times of wasm in browser
- Variable inside a Variable, not updating
Related Questions in HTML
- How to store a date/time in sqlite (or something similar to a date)
- How to use custom font during html to pdf conversion?
- Storing the preferred font-size in localStorage
- mp4 embedded videos within github pages website not loading
- Scrimba tutorial was working, suddenly stopped even trying the default
- Is there any way to glow this bulb image like a real light bulb
- With non-graphical maps in Leaflet, zoomDelta doesn't work
- What can I do to improve my coding on both html and css
- Uncaught TypeError: google.maps.LatLng is not a constructor at init (script.js:7:13)
- Bootstrap modal not showing at the desired position on a web page when the screen size is smaller
- Displaying a Movie List on a Website Using Jinja2 and Bootstrap
- How to redirect to thank you page after submitting a Google form embedded into a Google Site?
- Storing selected language in localStorage
- Fences (parenthesis, braces) in HTML and MathML
- Understanding Scroll Anchoring Behavoir
Related Questions in TOGGLE
- Is it possible to change multiple div elements' classes/properties with one button click?
- Rotating chevron in accordion in javascript
- Why is "toggle()" function not producing the same result as explicitly writing out a toggle?
- Why Flutter Switch onChanged Switch Back to Initial Place?
- How can i Assign all prefabs with a certain Tag to a List in Unity?
- JavaScript remove Attribute or Property won"t work
- Show details in recyclerview using toggle button in Toolbar
- Selecting all elements by specific class name and using toggle to change the class name
- Toggle Different Classes Sequentially
- How do I get the link text value to toggle using jQuery?
- React useState as a toggle triggers Re-render and re-initializes false on re-render
- Toggle for different height and width in JavaScript
- enable button with state of toggle
- Button in Header.vue that opens a Modal
- React using toggle switch to change state of sibling components
Related Questions in HIDE
- Override JS by hovering out of a div?
- If include the row below after the last name of every person, automatically the first visible name row should be hidden
- Android's Google services error, something with Magisk and Zygote SIGABRT (SIGNAL 6)
- How do I hide an entire HTML page, but make the page still renders and still exist?
- How to hide #document (Public URL) in browser source code that has already been encrypted?
- WooCommerce: Show or hide Out of Stock button depending upon stock conditions
- how do I hide an element depending on the variable?
- Hide Elementor accordion item if FacetWP is empty
- Hide all elements when the one element is visible
- Using a script to hide columns based on date values
- SSRS Hide Columns Based on Time Expression
- In youtube how to hide title text and light gradient when in full screen mode
- how to hide columns in ssrs expression
- loops in Django template
- How to hide Banner with media Query when it is 500 px and under
Related Questions in SHOW
- I can't make the last line spread across in my display
- showing loader while loading and show result when finished works fine in Firefox but not in Chrome
- WooCommerce: Show or hide Out of Stock button depending upon stock conditions
- How can I display the data after the user submits the form in Laravel 10?
- How to make a div stay visable after refresh
- Show/hide Javascript Toggle in the same page problem. Multiple hidden texts shows up in the same time. Without JQuery
- Show content after captcha submit
- Picture Show Preview
- TYPO3 gridelements accordeon show
- How to show form (own class) called in a hidden MainWindow class?
- jquery working only first item when another items was hidden
- how to Elfinderk img show
- The indicator does not move to a separate panel (Tradingview study error)
- How to show a small table by inputting a value in another cell
- how to Show Heads-up notification when app is closed
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
If you want to toggle different hidden text in multiple tables using different links, here's an example: