how to filter selected objects then hide objects not selected.

Posted by ussteele on Stack Overflow See other posts from Stack Overflow or by ussteele
Published on 2010-03-18T16:20:20Z Indexed on 2010/05/05 0:08 UTC
Read the original article Hit count: 181

Filed under:
|

following up from yesterday...

This portion of the code does work.

$(document).ready(function(){
$('#listMenu a').click(function (selected) {
        var getPage = $(this).attr('id');
        var getName = $(this).attr('name');

        //console.log(getPage);
        //console.log(getName);

            $(function() {
            $("#" + getName ).show();
            var getColor = $('#' + getName ).css('background-color');
            $('#header' ).css('background', getColor);
            $('#slideshow' ).css('background', getColor);
            $('span').css('background', getColor);
            $('#menuContainer').css('background', getColor);

        });

        $('li.listMenu ul').hide();
  });           
});

I am able to get what I wanted selected; based on vars getPage and getName, now I need to hide what is not selected.

I have tried this:

$(function() {
  var notSelected = $('div').filter(selected).attr('id', 'name');
  $(this).hide();
  console.log(notSelected);
});

placed just above: $('li.listMenu ul').hide();

but it's not correct, remember I am really a newbie.

what I see on screen is the new selected items on top of what should be hidden.

again any help is appreciated.

-sjs

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about filtering