Code JavaScript:<script type="text/javascript"> document.getElementById('collapse').innerHTML = 'Collapse all'; document.getElementById('expand').innerHTML = 'Expand all'; document.getElementById('bar').innerHTML = '|'; </script>
Thanks![]()
| SitePoint Sponsor |
Code JavaScript:<script type="text/javascript"> document.getElementById('collapse').innerHTML = 'Collapse all'; document.getElementById('expand').innerHTML = 'Expand all'; document.getElementById('bar').innerHTML = '|'; </script>
Thanks![]()

With what you're doing above you can't as there would be no way to set the HTML for each individual element if they would grouped together.
Blog/Portfolio | Evolution Xtreme | DFG Design | DFG Hosting | CSS-Tricks | Stack Overflow | Paul Irish
Having lame problems with your code? Let us help by using a jsFiddle

The best you could do to shorten this code would be to create a function so that you can remove the common part of each statement.
Code:set = function (id, txt) {document.getElementById(id).innerHTML = txt;} set('collapse','Collapse all'); set('expand','Expand all'); set('bar', '|');
Stephen J Chapman
javascriptexample.net, Book Reviews, follow me on Twitter
HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
<input name="html5" type="text" required pattern="^$">
Thanks Felgall. Is one way faster than the other? Negligible I know. It's wins on code length.
document.getElementById('collapse').innerHTML = 'Collapseall';document.getElementById('expand').innerHTML = 'Expandall';document.getElementById('bar').innerHTML = '|';
set = function (id, txt) {document.getElementById(id).innerHTML = txt;}set('collapse','Collapseall');set('expand','Expandall');set('bar', '|');
Bookmarks