简体   繁体   中英

How can I make a jQuery script for each image featured in wordpress?

I wish each of wordpress featured image to create special effect can hover ... please help me with an example in Jquery?

I would greatly help an example

I am a beginner and therefore appeal to your help

I am interested in the effect to be functional in Wordpress ... because static (else) know how to do this

Example can be about anything, I want to know how I can call all images featured in Jquery in WP.

Thanks in advance!

If all featured images has the same class (wp-post-image):

$('.wp-post-image').each(function(index,element){
 // $(element) is Your current featured image
 //add mouseenter and mouseleave event
 $(element).hover(function() {
  //add css class or style element with JS
  $( this ).addClass( "hover" );
 }, function() {
  //remove css class or style element with JS
  $( this ).removeClass( "hover" );
 });
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM