how do i make this function better without looking so jittery and glitchy and with possibly less code... (without the use of a plugin or an external function.
As far as the glitchiness... The reason why it is occurring is because the current instance is not being removed properly before the new color instance is faded in. Hence the old instance stays visible until the new instance has completed the animation cycle resulting in a glitchy look...That should give you some help in the general direction...Good Luck!
$(document).ready(function() { // attack a click event on all radio buttons with name 'category' $("input[name=category]").click(function() { var sel = $(this).val(); $('.' + sel).fadeIn('slow'); if (sel !== 'box') { $('.box:not(.' + sel + ')').fadeOut('fast'); } }); });
I changed the radio selection value for all from "all" to "box" to match the class name of all the boxes - it just made coding easier ;)
Oh and I removed the ":radio" from the input selector... I think it's going away in a future version of jQuery, so might as well get rid of it now.
The example from @timmey does not work . for somereason i can't seem to get it. and the second is partly disfunctional. when you switch from red to green to blue it words. but when going back to all, they all dissappear. and i can't seem to figure out how to make ALL of them re-appear.
Why not just use what @Mottie did? It uses fewer lines of code. The reason why Version 7 is not working is because you didn't change the value from all to box. :-)
ohhh in the HTML. there we go. it work. thankgoodness. how would i go about (code wise) fixing the glitch look... add a delay after the boxes dissappear, and before the new ones appear?
Totally got it! instead of fading it, i simply Hide the unselected ones. :) and shazaam! i got it! thank you so much for your help. and now i can use it for animals categories, or fav foods, or something a little more creative, like possibly wordpress image categories (like how faces works. OR for post types. filter through many post types. neat!
Wow, it feels weird being completely ignored... I had it working with the fadeOut eight posts ago... but hey, I guess I'm glad you got it working... and you're welcome.
how do i make this function better without looking so jittery and glitchy and with possibly less code... (without the use of a plugin or an external function.
This:
Becomes:
As far as the glitchiness... The reason why it is occurring is because the current instance is not being removed properly before the new color instance is faded in. Hence the old instance stays visible until the new instance has completed the animation cycle resulting in a glitchy look...That should give you some help in the general direction...Good Luck!
im no expert though.. :)
Oh and I removed the ":radio" from the input selector... I think it's going away in a future version of jQuery, so might as well get rid of it now.
most up-to-date version.
Why not just use what @Mottie did? It uses fewer lines of code. The reason why Version 7 is not working is because you didn't change the value from all to box. :-)
how would i go about (code wise) fixing the glitch look... add a delay after the boxes dissappear, and before the new ones appear?
thank you all for your help! much Appreciated.
- A.Hajzer
http://jsfiddle.net/attilahajzer/cCrky/embedded/result/