Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 02-05-2011, 04:45 PM show hide classes
Extreme Talker

Posts: 176
Trades: 0
HTML Code:
<script type="text/javascript">
    <!--
    var mode;
    function show(mode) {
            if (mode == 'approved') {
            document.approvedno.style.visibility = "hidden";
            alert('hidden');
            }
    
            if (mode == 'all') {
            document.approvedno.style.visibility = "visible";
            alert('shown');
            }
    }
    //-->
</script>

show: 
<a style="cursor: pointer;" onclick="javascript:show('all')">all</a>
<a style="cursor: pointer;" onclick="javascript:show('approved')">approved</a> 

<div class="approvedno" style="visibility: visible;">hide me</div>
<div class="approvedyes" style="visibility: visible;">don't hide me</div>
<div class="approvedno" style="visibility: hidden;">hide me</div>
<div class="approvedyes" style="visibility: hidden;">don't hide me</div>
I want to click a button and then change the style of all elements with a certain class. it's not working.
Skeddles is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-05-2011, 11:01 PM Re: show hide classes
Super Spam Talker

Posts: 879
Name: Paul W
Trades: 0
http://www.webmasterworld.com/forum91/2633.htm second ascript response
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE


*** New:
Please login or register to view this content. Registration is FREE
PaulW is online now
Reply With Quote
View Public Profile
 
Old 02-06-2011, 12:38 PM Re: show hide classes
Extreme Talker

Posts: 176
Trades: 0
Quote:
Originally Posted by PaulW View Post
neither of those examples seem to work

edit: I found another somewhere else that seemed to work though:
HTML Code:
function classAction(theClass){
 var allTags = document.getElementsByTagName('*');
 for(i=0; i<allTags.length; i++){
  if(allTags[i].className == theClass) allTags[i].style.display = 'none';
 }
}

Last edited by Skeddles; 02-06-2011 at 12:40 PM..
Skeddles is offline
Reply With Quote
View Public Profile
 
Old 02-07-2011, 08:52 AM Re: show hide classes
Extreme Talker

Posts: 246
Trades: 0
jQuery is kind of a perfect example for making something like this really easy.
pretty sure this would be the code:

$('.classname').css({display: 'none'});
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
stbuchok is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to show hide classes
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.55788 seconds with 12 queries