1

I have given html

<ul class="ui-multiselect-checkboxes ui-helper-reset" style="height: 175px;">
  <li class=" ">
    <label class="ui-corner-all" title="" for="ui-multiselect-opps-option-0">
      <input type="checkbox" title="" value="All" name="opps" id="ui-multiselect-opps-option-0">
      <i>All</i>
    </label>
  </li>
  <li class=" ">
    <label class="ui-corner-all" title="" for="ui-multiselect-opps-option-1">
      <input type="checkbox" title="" value="1" name="opps" id="ui-multiselect-opps-option-1">
      <i>John</i>
    </label>
  </li>
  <li class=" ">
    <label class="ui-corner-all" title="" for="ui-multiselect-opps-option-2">
      <input type="checkbox" aria-selected="true" checked="checked"  title="" value="3" name="opps" id="ui-multiselect-opps-option-2">
      <i>Tim</i>
    </label>
  </li>
  <li class=" ">
    <label class="ui-corner-all" title="" for="ui-multiselect-opps-option-3">
      <input type="checkbox" aria-selected="true" checked="checked" title="" value="2" name="opps" id="ui-multiselect-opps-option-3">
      <i>Tom</i>
    </label>
  </li>
</ul>

and have included given jquery code

$("input[id^='ui-multiselect-opps-option']").attr('checked').val();

but its not fetching checked values please guide me how to fetch multiselect checked values through jquery.

1 Answer 1

2

Use .map() in jquery. It is used to translate all items in an array or object to new array of items.

var res = $("input[id^='ui-multiselect-opps-option']:checked").map(function() {
  return $(this).val();
}).get();

 console.log(res);

Fiddle

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.