Skip to content
Fix Code Error

JavaScript hide/show element

March 13, 2021 by Code Error
Posted By: Anonymous

How could I hide the ‘Edit’-link after I press it? and also can I hide the “lorem ipsum” text when I press edit?

<script type="text/javascript">
function showStuff(id) {
  document.getElementById(id).style.display = 'block';
}
</script>


<td class="post">

  <a href="#" onclick="showStuff('answer1'); return false;">Edit</a>
  <span id="answer1" style="display: none;">
    <textarea rows="10" cols="115"></textarea>
  </span>

  Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum 
</td>

Solution

function showStuff(id, text, btn) {
    document.getElementById(id).style.display = 'block';
    // hide the lorem ipsum text
    document.getElementById(text).style.display = 'none';
    // hide the link
    btn.style.display = 'none';
}
<td class="post">

<a href="#" onclick="showStuff('answer1', 'text1', this); return false;">Edit</a>
<span id="answer1" style="display: none;">
<textarea rows="10" cols="115"></textarea>
</span>

<span id="text1">Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum</span>
</td>
Answered By: Anonymous

Related Articles

  • How do I include certain conditions in SQL Count
  • Is CSS Turing complete?
  • How to convert image into byte array and byte array…
  • How to pass 2D array (matrix) in a function in C?
  • How to create a dynamic form vuejs vuetify?
  • Reference - What does this regex mean?
  • How do i update a javascript variable as its value changes?
  • Javascript validate all checkboxes are selected
  • How to prevent scrolling the whole page?
  • Is it possible to apply CSS to half of a character?
  • creating a python 2 player game with functions & classes
  • Active tab issue on page load HTML
  • Navbar not filling width of page when reduced to mobile view
  • .map is not returning the values(not a function)
  • laravel vuejs/axios put request Formdata is empty
  • Fix top buttons on scroll of list below
  • Footer not staying at the bottom when scrolling
  • How to use html template with vue.js
  • Regex on htaccess file gives INTERNAL REDIRECT error
  • Show/hide 'div' using JavaScript
  • center 3 items on 2 lines
  • showing record text with red color when click stop button
  • After a little scroll, the sticky navbar just is not…
  • Checkbox filtering with VueJS
  • Why doesnt my table sort my div variable in numerical order?
  • Three.js: Cannot display mesh created with texture array
  • Sorting A Table With Tabs & Javascript
  • Vuetify grid system row management
  • Python game with list of dictionaries/ each question…
  • Trying to keep dropdown menus flush to the edge of…
  • CSS gradient animation degree change
  • Right Align in Vuetify Toolbar
  • When clicked, hide others and so on [Code optimisation]
  • jQuery + MarkItUp + Polymer - Getting it to Work?
  • Keep button focused when using mulitple button groups
  • How to create a game over screen for a basic HTML/JS game?
  • Sort table rows In Bootstrap
  • Adobe XD to responsive html
  • "Next" Arrow Disappearing Too Early in Carousel
  • javascript .replace and .trim not working in vuejs
  • Smart way to truncate long strings
  • VueJS how to rerender a component
  • Vue : Limit characters in text area input, truncate filter?
  • Vuetify 2.2 DataTable multiple filters
  • How to show title in hover - css / jquery
  • JavaScript gives NaN error on the page but variable…
  • Refresh v-model
  • HTML5 best practices; section/header/aside/article elements
  • Why my "title" bloc doesn't go to bottom?
  • Disabling a button upon condition in Google App script
  • Bootstrap - center child when parent isn't centered…
  • Open/Close content and anchor link
  • how to use canvas in JavaScript flappy bird code
  • Edit Firebase data using VueFire
  • Pop up doesn't disappear when I click "Stop Capture"…
  • How do you sort table columns with Vue.js?
  • Displaying the Dates that user have chosen from date input
  • Edit item description in array in Vue JS
  • Incorporate JQuery-file-upload to application
  • What causes the error "undefined reference to (some…
  • How can I center all my contents in html?
  • Simple Popup by using Angular JS
  • How to add fade animation for this tab
  • Enumerate a string in Elixir
  • how to toggle class for multiple elements in vue js
  • Twitter Bootstrap Button Text Word Wrap
  • Convert Xml to DataTable
  • How to add a div with bootstrap form elements dynamically?
  • OpenCV Object detection with Feature Detection and…
  • state data can not be set using useState in reactjs
  • Polymer.js two-way binding to textarea value
  • setTimeout function not working : javascript
  • Having trouble with my nav bar/header, It used to…
  • jQuery multiple form repeater
  • Applying an ellipsis to multiline text
  • on input event not working on when using button value
  • How to autosize a textarea using Prototype?
  • using underscore templates with backbone.js
  • Highlight a word with jQuery
  • CSS Float: Floating an image to the left of the text
  • How to get Navigation drawer clipped under dialog…
  • How to iterate through property names of Javascript object?
  • Avoid using document.getElementById with Backbone.js
  • How to add space between cards in same row in vuetify
  • When tab is selected, show next tab.. if last tab…
  • R dplyr: Drop multiple columns
  • Vuetify - Rules should return a string or boolean,…
  • Polymer Elements ShadowDOM child nodes - Setting…
  • How do I position these HTML elements with CSS?
  • Javascript and css animation
  • Handlebars If statement inside each loses context
  • Onclick, the button moves down, why can that due to?
  • JavaScript validation for empty input field
  • How to fix clipped text disappearing in Firefox?
  • Change element type at runtime
  • How do you dynamically allocate a matrix?
  • Bootstrap Vue perPage for custom columns or rows
  • numpy division with RuntimeWarning: invalid value…
  • I need help figuring out how to add values
  • paper-dialog stretching off screen

Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.

Post navigation

Previous Post:

Resolve Git merge conflicts in favor of their changes during a pull

Next Post:

How to compare dates in Java?

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

.net ajax android angular arrays aurelia backbone.js bash c++ css dataframe ember-data ember.js excel git html ios java javascript jquery json laravel linux list mysql next.js node.js pandas php polymer polymer-1.0 python python-3.x r reactjs regex sql sql-server string svelte typescript vue-component vue.js vuejs2 vuetify.js

  • you shouldn’t need to use z-index
  • No column in target database, but getting “The schema update is terminating because data loss might occur”
  • Angular – expected call-signature: ‘changePassword’ to have a typedeftslint(typedef)
  • trying to implement NativeAdFactory imports deprecated method by default in flutter java project
  • What should I use to get an attribute out of my foreign table in Laravel?
© 2022 Fix Code Error