-1

I'm not sure if this is the correct term (child element) but I have CSS I need to change with JavaScript. How do I make this text area field visible?

#desc {
 display = 'none';
}

#desc textarea {
     display: none;
     background-color: red;
}


<div id='desc'>
     <textarea> </textarea>
</div>

var x = document.getElementById('desc').style.display = 'block';
var t = document.getElementById('textarea').style.display = 'block';
isherwood
  • 58,414
  • 16
  • 114
  • 157
alex mac
  • 11
  • 1
  • possible duplicate of [How do I change the background color with JavaScript?](http://stackoverflow.com/questions/197748/how-do-i-change-the-background-color-with-javascript) – Bono Mar 02 '15 at 01:05
  • `#Desc textarea` should be `#desc textarea` and `document.getElementById('textarea')` won't work because no element has the ID of `textarea`. And `display = 'none';` should be `display:none;` – j08691 Mar 02 '15 at 01:09
  • `document.querySelector('#desc textarea').style....` – adeneo Mar 02 '15 at 01:10
  • The "var t" line doesn't seem to work, I can make the #desc div visible but i CANNOT get the text area to be visible as well because it is INSIDE the desc div and the CSS property (dec -> textarea) is specifically set to 'none' I cannot figure out how in JAVASCRIPT to access that text area property. – alex mac Mar 02 '15 at 01:10

1 Answers1

0

Try the following:

document.getElementById('desc').style = 'display:block';
document.getElementByTagName('textarea')[0].style = 'display:block';

Or,

document.querySelector('#desc textarea').style = 'display:block;'1

1 Credits to @adeneo

Community
  • 1
  • 1
A.J. Uppal
  • 19,117
  • 6
  • 45
  • 76