Hi! I am a newbe as it comes to jQuery.. I'm working on my portfolio, and i'm stuck.. I have a page with all portfolio-items (images) that can be sorted by category. So when i press on category 'Art', all the other catergory's turn to a low opacity so the selected category stay''s highlighted. See it working here: link text
But when I hover over the items with the low opacity, they become highlighted again. How do i lock this .hover function temporary so that when a category is selected, the other items (images) do nothing when hovered?
this is the code i used for the hover in the index.html (this for each category):
var $j = jQuery.noConflict();$j(document).ready(function(){
$j(".art").css({opacity: 0}); // Loaded at 0 opacity
$j(".art").fadeTo(900, 0.8); // Onload fade items to 80%
$j(".art").hover(function(){
$j(this).fadeTo("fast", 1.0); // Rollover at 100%
},function(){
$j(this).fadeTo("fast", 0.8); // Rollout at 80%
});
});
And this code for the category filter (code is a external .js file):
$(document).ready(function() {
$('ul#navfilter a').click(function() {
$(this).css('outline','none');
$('ul#navfilter .current').removeClass('current');
$(this).parent().addClass('current');
var filterVal = $(this).text().toLowerCase().replace(' ','-');
if(filterVal == 'all') {
$('.wrap .hidden').fadeTo('slow' ,0.8).removeClass('hidden');
} else {
$('.wrap .masonryWrap > div').each(function() {
if(!$(this).hasClass(filterVal)) {
$(this).fadeTo('slow' ,0.08).addClass('hidden');
} else {
$(this).fadeTo('slow' ,0.8).removeClass('hidden');
}
});
}
return false;
});
});
I hope someone can help..
Thanks!
------edit-----
Oké i changed the event-handler in the first codeblock to:
$j(".art").hover(function() {
if ( ! j$(this).hasClass("hidden") ) {
$j(this).fadeTo("fast", 1.0);
} // Rollover at 100%
},function(){
if ( ! j$(this).hasClass("hidden") ) {
$j(this).fadeTo("fast", 0.8); // Rollout at 80%
}
});
Like CrazyJugglerDrummer said. But now the hover function doesn't work at all.. And I got a syntax error on a line far further in the document (see last line below):
<script type="text/javascript">$(function(){
//run masonry when page first loads
$('.wrap').masonry();
//run masonry when window is resized
$(window).resize(function() {
$('.wrap').masonry();
});
}) //syntax error on this line </script>
Now i putted in the 'noConflict' and followed 'RUSS CAM's advice like this:
<script type="text/javascript">
jQuery.noConflict();jQuery(document).ready(function($) {
//run masonry when page first loads
jQuery('.wrap').masonry();
//run masonry when window is resized
jQuery(window).resize(function() {
jQuery('.wrap').masonry();
});
}); // Still syntax error on this line
</script>
But now i still got the syntax error on the last line from above.
Am I doing something wrong here?