开发者

Access a Div inside a Div (JQuery)

I got a problem with accessing a Div's attribute inside another D开发者_运维知识库iv. I'm using the JQuery Plugin QuickFlip and want to change the background image of the back.

<div class="quickFlip">
  <div class="blackPanel"> </div>
  <div class="redPanel">
    <p class="quickFlipCta">Click to Flip</p>
  </div>
</div>

This is the structure of one of my panel. (I got more of them all with the same class name). With this code I loaded one of the panels into the variable "div".

$(div).quickFlipper();

div = $(".quickFlip").get().sort(function(){ 
  return Math.round(Math.random())-0.5;
}).slice(0,1);

Now I want to access the background image... I already tried this:

$(div).$('redPanel')({'background': 'url(tiles/' + images[Math.floor(Math.random() * images.length)] + ')'});

which was actually not working... ^^ I was able to change the background of the quickFlip class with this code but not the background of the redpanel...

Hope you guys can help me!


Don't be afraid to use more local variables.

var i = Math.floor(Math.random() * images.length),
    bg = 'url(tiles/' + images[i] + ')';

$(div).find('div.redpanel').css('background-image', bg);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜