0

onSlide イベントの使い方が分からず、jquerytools のフォーラムが機能していないようです

基本的に、onchange ではなく、スライドで現在の範囲値を取得したいと考えています。

これが私がonchangeのために取り組んでいるものですが、範囲セレクターをスライドさせながら現在の値を取得したいと思います。

http://jsfiddle.net/rx3AJ/

私が試してきたJS:

$(function () {

      $("#slideshow img").each(function(index, element){$(element).attr("id", index+1);});    

      var count = $("#slideshow img").length;

      $('#slideshow img:gt(0)').hide();
      $("#date p").text($("#slideshow img#1").attr("alt"));

      $(":range").rangeinput({
            precision: 0, value: 1, min: 1, max: count,
            onSlide: function() {
                console.log("you\'re sliding");
                //this is where i want to update do stuff on slide I think? but it won't work
                return true;
              }   
        });

      $(':range').bind('onSlide', function(){})
      $(":range").change(function(event, value) {
          //i'd like to do this onslide
          console.info("value changed to", value);
          $('#slideshow img').hide();
          $('#slideshow img#' + value).show();
          $("#date p").text($("#slideshow img#" + value).attr("alt"));
      });

  });​

手がかりがないので、どんなアイデアでも大歓迎です...

4

1 に答える 1

0

まず、jsfiddleにはjQueryツールライブラリが含まれていないため、使用しないでください。次に、範囲入力コードを次のように変更します。

$(":range").rangeinput({
    precision: 0, value: 1, min: 1, max: count,
    onSlide: function(event, i) {
        $('#slideshow img').hide();
        $('#slideshow img').eq(i).show(); 
        // the way you had works too, but you don't have to assign id's this way
        $("#date p").text($("#slideshow img").eq(i).attr("alt"));

    }   
});

また、jQueryツール(jQueryを含む)を必ず含めてください

于 2012-08-24T15:03:40.293 に答える