开发者

Using a custom variable in a 3rd party jQuery plugin

I am not so great at writing jQuery yet so pardon the naive question:

I would like the place the value of a clicked href into the 'backstretch' jQ plugin. ( http://srobbin.com/jquery-plugins/jquery-backstretch/ )

my code looks like this:

$(function() {

    var bgImage = $('.active').attr("href"); //gets the value of the href on the a with the class 'active' and puts it in a variable.


    $('.clicks a').click(function() {
        $('.clicks a').removeClass('active');
        $(this).addClass('active');
        return false;
    }) //removes all 'active' classes, and puts the 'active' class on the clicked a tag.


    $.backstretch("bgImage", {speed: 150}); // uses the value the variable in this plugin.

}); //end.ready

Its not working thoug开发者_StackOverflow社区h, any ideas? Thanks in advance!


Ok, I got it. This is how i did it incase anyone is wondering:

$(function() {
  $.backstretch("<?php bloginfo('template_url'); ?>/images/tn_bg2.jpg", {speed: 150});
  $('.clicks a').click(function() {
    var happy = $(this).attr('href');
      $(this).fadeIn('slow', function() {
        $("#backstretch img").attr("src", happy);

      });
      return false;
  });
}); //end.ready
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜