72 posts
  • Has been part of the Envato Community for over 2 years
  • Has collected 1+ items on Envato Market
mattmatt88 says

I have a quick jquery-question. I’ve got the following function

$('#post-1', this).hover(function() {

But I want the function for all posts, not just for post #1. It doesn’t work if I type ”#post” or ”#post-” etc.

Can you help me?

745 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+3 more
Gareth_Gillman says

you will need to add a new class to the posts e.g. class=”hover”.

You will then be able to attack every post with that class.

I am guessing this is in WordPress which might be using the following to give current ID

<div id="post-<?php the_ID(); ?>"> // code here </div>

So just add a class onto the end before the final > e.g.

<div id="post-<?php the_id(); ?>" class="class-name"> // code here </div>
72 posts
  • Has been part of the Envato Community for over 2 years
  • Has collected 1+ items on Envato Market
mattmatt88 says

Shame on me that I haven’t checked this out by myself. thanks.

But I have another syntax problem. I have a Variable “imgwidth” that I want to include in the wrap function. It doesn’t work like that:

$(this).wrap('<div style="background-color:#000; width:', imgwidth ,';">');

It also doesn’t work with “&quot” instead of the “

Do you have an idea?

72 posts
  • Has been part of the Envato Community for over 2 years
  • Has collected 1+ items on Envato Market
mattmatt88 says
by
by
by
by
by
by