1

Im trying to get the value of an html element via Id. I now want to use that value to loop through all the elements with the class from the id.val. How can I search for a variable as a class.


$(".BtnSettings").click(function () {
        var Daytime = $("#Daytime").val();
//Here i dont know what to do. Instead of .Daytime I want to search for the var Daytime. Or for $("#Daytime").val() obviously, doesnt matter.
        $('.Daytime').each(function () {
            $(this).prop("checked", true); // Element(s) are now enabled.
        });
    })
Mischa Morf
  • 331
  • 1
  • 4
  • 14

1 Answers1

-1

you can use the attr method of jquery to look for a specific attribute just set a value. if you want to change value of said attribute the second parameter of the function will set it for you like.

Daytime.attr("class","newClass")
$("#Daytime").attr("class") 

will give you the class of #Daytime

treyBake
  • 6,440
  • 6
  • 26
  • 57
Nyuu
  • 65
  • 1
  • 8