82 posts
  • 3 Years of Membership
  • Austria
  • Collector Level 1
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?

1096 posts
  • 5 Years of Membership
  • Affiliate Level 1
  • Beta Tester
  • Collector Level 2
+5 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>
82 posts
  • 3 Years of Membership
  • Austria
  • Collector Level 1
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?

82 posts
  • 3 Years of Membership
  • Austria
  • Collector Level 1
mattmatt88
says
by
by
by
by
by
by