0

I want to return selected text, instead of value. I know how to return value:

$("#myid").multiselect("getChecked").map(function(){
     return this.value
}).get().join(",");

but I dont know how to get text. I tried in map function this.text, this.val() and so on, but none of that is working. Please help..

1
  • do you mean "$(this).text()" (as a jquery function) ? Commented Feb 20, 2013 at 14:16

3 Answers 3

3

The multiSelect I could find uses TITLE to hold the text value

DEMO

$( "#myid" ).multiselect("getChecked").map(function(input){
   return input.title;
}).get().join(",");
Sign up to request clarification or add additional context in comments.

Comments

1

DOM Element object doesn't have text property, you can use textContent property of DOM Element object or jQuery text method:

var texts = $("#myid").multiselect("getChecked").map(function(){
    return this.textContent || this.innerText;
    // return $(this).text();
}).get().join(",");

4 Comments

@mplungjan DOM Element object doesn't have text property. textContent is supported by standard browsers and innerText is supported by IE.
@mplungjan Can you provide a demo?
Hmm, I was going to, but multiselect("getChecked") sounds like a jQuery UI widget rather than an actual <select> object
@mplungjan They have value property but not text property.
0

There is jQuery method .html() method to get the innerHTML.

        $("#myid").multiselect("getChecked").map(function(){
           return this.html();
}).get().join(",");

1 Comment

i think you mean return $(this).html();

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.