5

Hello I got a rather simple question. I use the HTML5 range slider type: <input type="range"> and I want to trigger it via jQuery.

I used the following code:

$("form input:range").each(function () {
    // Do something
});

For some reason I get the following error:

! Uncaught Error: Syntax error, unrecognized expression: unsupported pseudo: range

Perhaps important: I use jquery-1.12.1.min.js.

Does anyone now why this is and how I could solve this?

Pranav C Balan
  • 113,687
  • 23
  • 165
  • 188
Rotan075
  • 2,567
  • 5
  • 32
  • 54

3 Answers3

6

Try this:

jQuery("input[type=range]")

: is for getting some kind of meta information, usually related to what the user is doing with the element.

For example: :hover only applies to elements the user has placed the cursor over and :visible is elements the user can see.

EDIT

Pranav C Balan's answer better explains what is going on: HTML5 range - unsupported pseudo: range

Community
  • 1
  • 1
Emil S. Jørgensen
  • 6,216
  • 1
  • 15
  • 28
5

There is no :range pseudo selector in css or jQuery. Instead you can use attribute equals selector

$("form input[type='range']").each(function () {
    // Do something
});

For all supported selectors list visit : JQuery Selectors

Pranav C Balan
  • 113,687
  • 23
  • 165
  • 188
1

Yes, you need to use attribute equals selector:

jQuery("input[type=range]")

There's use of :in-range or :out-of-range css selector that you can use for min and max value range:

$("form input:in-range").each(function () {
    // Do something
});

But alas! There's no :range selector.

Bhojendra Rauniyar
  • 83,432
  • 35
  • 168
  • 231