Check if inputs have specific value
I've been scratching my head and either got it completely wrong or close...
I have div that displays and number e.g. 106
I then want to run a query that will take that ID and check if any inputs values on the same page has that number.
If one does have that value, then the input gets ticked.
However all I get is undefined.....
- var dev_id = jQuery('.dev_title').text();
- alert(dev_id);
- if (jQuery(".dev_id").val() === dev_id) {
- jQuery(this).prop('checked', true);
- alert(dev_id);
- }
- <span class="dev_title">106</span>
- <div class="dropdown">
- <label>
- <input type="checkbox" class="dev_id" value="92"> Brewary A
- </label>
-
- <label>
- <input type="checkbox" class="dev_id" value="106"> Brewary B
- </label>
-
- <label>
- <input type="checkbox" class="dev_id" value="392"> Brewary C
- </label>
- </div>