Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-01-07 07:19:06

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

Help sorting this one out please

OK – so I have this article form for 4 articles:

<div class="teampics corner" onclick="location.href='<txp:permlink />';" style="cursor: pointer;background: #fff url(<txp:upm_article_image form="bgimage" offset="1" limit="1" />) no-repeat; background-position: 0px 0px;"></div>

I’m trying to create rollovers from an article image by changing the background position of the divs with jquery.

<script type="text/javascript"> $(document).ready(function(){ $('.teampics').hover(function(){ $('.teampics').css('backgroundPosition', '0px -94px'); }, function(){ $('.teampics1').css('backgroundPosition', ''); }); }); </script>

But what happens is they all rollover at the same time (kind of like some bad planning on my side) – so I think I need a way to make them all unique by adding a number (or something) which I can then add to the css and jquery to make them work individually.

So I’m looking for:

1) a way to number them incrementally (I tried rvm_counter – but it changed the value on every refresh – couldn’t see a way of making it work how I wanted)
2) Is there a way to make a css style work on a div which has part of the name (so .style {color:red}; works on .style-1, .style-2, .style-3 etc
3) The same as above which works with Jquery :)

I’ve haven’t come across 2 or 3 before and I’ve searched all arvo, so just wondering if anyone of you know of a way.

BTW – I think there will only be 4 articles – so if I can get 1 working, I can work out a way for 2 & 3

Thanks

Tye

Last edited by tye (2010-01-07 07:19:56)

Offline

#2 2010-01-07 10:10:57

phuture303
Member
Registered: 2008-09-14
Posts: 127

Re: Help sorting this one out please

1) Maybe you can try <txp:article_id /> to give each div-class its individual ID?

<div class="teampics-<txp:article_id /> ...

…and do the same in the script?

(untested :)

Last edited by phuture303 (2010-01-07 10:11:25)

Offline

#3 2010-01-07 10:58:28

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

Re: Help sorting this one out please

Perfect – well that sorts that out, Thanks :)

It would be really nice though to discuss if 2 & 3 are possible.

With my knowledge I think not, but who knows :)

Thanks again phuture303, sometimes I think things are more involved that they are :)

Offline

Board footer

Powered by FluxBB