mercredi 8 juin 2016

Issue in Fetch the color from dropdown option in jQuery

I want to fetch the color on change event of dropdown value.

following is the structure of dropdown.

<select id="task_result_task_result_status_id" name="task_result[task_result_status_id]" style="color: #57a90f;">

<option value="" style="color: #696762;">Please Select</option>

<option value="1" style="color: #000000;">In Progress</option>

<option value="6" style="color: #000000;">Test</option>

<option value="3" style="color: #57a90f;" selected="selected" data-completion-status="">Completed/Compliant/Yes</option>

<option value="2" style="color: #e11d2b;" data-completion-status="">Not Completed/Non Compliance/No</option>

<option value="4" style="color: #fa7603;" data-completion-status="">Not Applicable</option>

<option value="7" style="color: #ef0707;" data-completion-status="">Test Complete</option>

Code-

 var statusSelect = jQuery('#task_result_task_result_status_id');
  statusSelect.change(function () {
  alert($( '#' + status_select_id+ ' option:selected' ).css('color'));
  var selected = statusSelect.find('[value="' + statusSelect.val() + '"]');
  if (selected.length > 0)
    alert(selected.css('color'));
});

both alert return rgb(255,255,255).

May In know where is the Issue?

Aucun commentaire:

Enregistrer un commentaire