John M wrote:
I want to hide the first row in my table and if a user click on a show
button than show it. If it is visible than user can hide it with click a
hide button.
In default I hide it with:
<tr id="ds" style="display:none">
but how can I make it visible or hide it dynamicaly?
function hideElement (elementId) {
var element;
if (document.all)
element = document.all[elementId];
else if (document.getElementById)
element = document.getElementById(elementId);
if (element && element.style)
element.style.display = 'none';
}
function showElement (elementId) {
var element;
if (document.all)
element = document.all[elementId];
else if (document.getElementById)
element = document.getElementById(elementId);
if (element && element.style)
element.style.display = '';
}
Now you can call
showElement('ds');
to show the table row.
However as not all browsers support JavaScript and even some of those
that do don't support toggling style.display it is better if you don't use
<tr id="ds" style="display:none">
to hide the row but rather do it with script e.g.
<table>
<tr id="ds">
<td>...</td>
...
</tr>
...
</table>
<script type="text/javascript">
hideElement('ds');
</script>
--
Martin Honnen
http://JavaScript.FAQTs.com/