Can I get the attributes of individual elements that jQuery selects during selection?

I am using jQuery and jQuery UI Slider to display some controls on my HTML page, and I want to set the slider range from an attribute in my HTML.

Here is the code I use to initialize the sliders ...

$( ".slider" ).slider(
  {
    range: "min",
    value: 0,
    min: 0,
    max: 5,
    slide: handleSlide
  }
);

Of course, the maximum value is hardcoded. What I would like to do in my code is ...

<div class="slider" id="sliderA" max="10"></div>

but I can’t figure out how to get the attribute during selection.

I thought that I have access to it through this, as in JQuery .each(), but firebug tells me that this is a document, so it does not work.

I want to do something like ...

$( ".slider" ).slider(
  {
    range: "min",
    value: 0,
    min: 0,
    max: blah.getAttribute("max"),
    slide: handleSlide
  }
);

but I can’t understand what could be blah.

? , JQuery , , - , , .

+3
3
    $( ".slider" ).each(function()
    {
     $(this).slider(
      {
        range: "min",
        value: 0,
        min: 0,
        max: $(this).attr("max"),
        slide: handleSlide
      }
    );
    });
+2

, .

, slider. $ .

.slider() .each, .
, each, this each.

+1

, - "max" :

    $('.slider').each(function (index) {
        $(this).slider({
            max: $(this).attr('max'),
            slide: function (event, ui) {
                console.info(ui.value);
            }
        });
    });
0

All Articles