0
從昨天開始跟進...如何過濾所選對象,然後隱藏未選中的對象
這部分代碼確實有效。
$(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();
});
});
我能夠得到我想要的東西;基於vars getPage和 getName,現在我需要隱藏未選中的內容。
我已經試過這樣:
$(function() {
var notSelected = $('div').filter(selected).attr('id', 'name');
$(this).hide();
console.log(notSelected);
});
放在略高於:$('li.listMenu ul').hide();
但它是不正確的,記得我是一個真正的新手。
我在屏幕上看到的是應該隱藏的新選定項目。
再次讚賞任何幫助。
-sjs