jQuery filter options with value greater (less) than variable

Jaroslav

I need to disable values of options in select that are less than some number, which I do not know beforehand (it is set in another form element). I need something like code below, but with variable value of "variableInteger":

select.children().filter(function() {
  return $(this).attr("value") > variableInteger;
}).each(function () {$(this).attr('disabled', 'disabled')});

Is there some clever way to do it?

PS. variableInteger value is from another form element, which name is also known only at runtime.

tymeJV

No need for the .each, also make use of prop and this.value (no need for $(this).attr("value");)

select.children("option").filter(function() {
    return this.value > variableInteger;
}).prop("disabled", true);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

jQuery: remove select options greater than and less than

From Dev

Jquery html "select" hide options with value greater than specified

From Dev

Greater than and Less than Value SSRS 2008

From Dev

If value is greater than, less than and becomes greater than again

From Dev

If value is greater than, less than and becomes greater than again

From Dev

How to filter SQL by time (greater and less than)?

From Dev

how to disable dropdown options less than some value using jquery

From Dev

Making a variable a 'less than' value?

From Dev

Making a variable a 'less than' value?

From Dev

Can C# use #if to compare a value with less than or greater than?

From Dev

How to find numbers in an array that are greater than, less than, or equal to a value?

From Dev

matplotlib boxplot to plot < > greater than and less than a certain value

From Dev

Excel: Select the cell to the left that is greater than/less than some value

From Dev

Python-Less than/ greater than value returns

From Dev

Greater than or Less than equal to

From Dev

if greater than or less than and zero

From Dev

Jquery if value is greater than a certain length

From Dev

Python Less/Greater than issue

From Dev

SQL Update Statement Where Value Must Be Greater Than the Previous Value But less Than the next

From Dev

AngularJS : ng-repeat filter when value is greater than

From Dev

filter groups where max value is greater than limit

From Dev

AngularJS : ng-repeat filter when value is greater than

From Dev

Implement Value Filter lest then and greater than in 2sxc module

From Dev

Spatial data structure for finding all points greater than or less than a value in each cartesian dimension

From Dev

How to specify a validation rule in Yii2 which will be greater than or less than of a specific number or value?

From Dev

How to get Documents less than or greater than some value in mongodb using java

From Dev

greater than and less than equals to in sql?

From Dev

Creating a greater than but less than function in XML

From Dev

Strange Greater than or Less than Results

Related Related

  1. 1

    jQuery: remove select options greater than and less than

  2. 2

    Jquery html "select" hide options with value greater than specified

  3. 3

    Greater than and Less than Value SSRS 2008

  4. 4

    If value is greater than, less than and becomes greater than again

  5. 5

    If value is greater than, less than and becomes greater than again

  6. 6

    How to filter SQL by time (greater and less than)?

  7. 7

    how to disable dropdown options less than some value using jquery

  8. 8

    Making a variable a 'less than' value?

  9. 9

    Making a variable a 'less than' value?

  10. 10

    Can C# use #if to compare a value with less than or greater than?

  11. 11

    How to find numbers in an array that are greater than, less than, or equal to a value?

  12. 12

    matplotlib boxplot to plot < > greater than and less than a certain value

  13. 13

    Excel: Select the cell to the left that is greater than/less than some value

  14. 14

    Python-Less than/ greater than value returns

  15. 15

    Greater than or Less than equal to

  16. 16

    if greater than or less than and zero

  17. 17

    Jquery if value is greater than a certain length

  18. 18

    Python Less/Greater than issue

  19. 19

    SQL Update Statement Where Value Must Be Greater Than the Previous Value But less Than the next

  20. 20

    AngularJS : ng-repeat filter when value is greater than

  21. 21

    filter groups where max value is greater than limit

  22. 22

    AngularJS : ng-repeat filter when value is greater than

  23. 23

    Implement Value Filter lest then and greater than in 2sxc module

  24. 24

    Spatial data structure for finding all points greater than or less than a value in each cartesian dimension

  25. 25

    How to specify a validation rule in Yii2 which will be greater than or less than of a specific number or value?

  26. 26

    How to get Documents less than or greater than some value in mongodb using java

  27. 27

    greater than and less than equals to in sql?

  28. 28

    Creating a greater than but less than function in XML

  29. 29

    Strange Greater than or Less than Results

HotTag

Archive