JSFiddle - React, Tailwind, and code Playground

by Agostino Pesapane

HTML

<form>
  <select class="form-control" id="follower_id" name="event[task_followers_attributes][0][follower_id]">
    <option value=""></option>
    <option data-typeahead-associated-id="1" value="1" selected>Administrator</option>
    <option data-typeahead-associated-id="2" value="2" >Marketing Guy</option>
  </select>
  <input type="hidden" data-typeahead-associated-id="2" name="event[followers_attributes][1][id]" value="2">  
</form>

<div id="result">
</div>

</div>
</div>

JavaScript

var elements = $('form').find('[data-typeahead-associated-id]');
var result = elements.filter(":selected, :checked, :input");
$.each(result, function(index, value){
		$('#result').append("<p>Index: " + index + " | Element: " + value + " | Value: " + $(value).val() +"</p>");
	});