Hi there,
I have created 4 columns for my pricing table. I want to fade all other columns to 0.5 opacity when hovering over one of the columns. I need to add some jquery to make this work but I'm not sure where I would place the jquery?
Thanks
Hi there,
I have created 4 columns for my pricing table. I want to fade all other columns to 0.5 opacity when hovering over one of the columns. I need to add some jquery to make this work but I'm not sure where I would place the jquery?
Thanks
Hi,
1) create a new .js file, let's say "flare-child-theme/custom.js"
2) open "flare-child-theme/functions.php"
3)
add this code
function btp_flarechild_enqueue_scripts(){
wp_register_script('custom', get_stylesheet_directory_uri() . '/custom.js', array('jquery', 'main'),'1.0');
wp_enqueue_script('custom');
}
add_action( 'wp_enqueue_scripts', 'btp_flarechild_enqueue_scripts' );
voila :)
this way all your JS will be placed inside the flare child theme, leaving parent theme untouched
regards,
Michael
Great, thank you! Do I need to add something first in the javascript file or do I just go and paste the code in there?
When I just paste this, I get an error:
$(document).ready( function () {
$('.li_class').hoverIntent(function(){
$(this).removeClass('fade').siblings().animate({ opacity: 0.5 }, 500);
},function(){
$(this).siblings().andSelf().animate({ opacity: 1 }, 100);
});
});
Don't worry, I've fixed it but the code doesn't seem to be working.
Perhaps you can help? I have 4 columns in my pricing table. When I hover over one of the columns, I want the other columns to fade out.
How can I achieve this effect? Thank you :)
Are you sure custom.js is loaded?
You can check it in the firebug, or directly in the source code
regards,
Michael
Yeah it's loaded, but the code I'm using doesn't seem to achieve the effect I want:
$(document).ready( function () {
$('.column-normal').hoverIntent(function(){
$(this).removeClass('column-fade').siblings().animate({ opacity: 0.5 }, 500);
},function(){
$(this).siblings().andSelf().animate({ opacity: 1 }, 100);
});
});
Maybe try without hoverIntent, just regular hover event
regards,
Michael
I'm not sure what you mean by this? Could you explain a bit more please? Thanks
This website's pricing table is an example of the effect I want - http://www.shopify.com/pricing.
Are they achieving the fade in/out with jquery or just css?
hoverIntent is not a regular JS event - in fact it's a plugin which fakes a "delayed hover ".
So in your code, you should try to use hover event instead
regards,
Michael
You must log in to post.