使用selectize从选定内容获取文本 [英] Get Text From Selected using selectize

查看:113
本文介绍了使用selectize从选定内容获取文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试过了:

var eventHandler = function() {
    return function() {
        console.log($select.val());
    };
};
var $select = $('.selectize').selectize({
    create          : true,
    onChange        : eventHandler()

});

哪个可以让我获得所选选项的值,但是我需要文本.当我这样做时:

Which get me the value of the selected option but I need the text. When I do this:

console.log($select.val().text());

我得到一个错误.我尝试了其他方法都无济于事.如何获取所选文本?

I get an error. I've tried other things to no avail. How do I get the selected text?

推荐答案

select_option.getItem(select_option.getValue())[0].innerHTML; select_option = $select_option[0].selectize; 以获得指定下拉选项的文本值.

select_option.getItem(select_option.getValue())[0].innerHTML; select_option = $select_option[0].selectize; to get text value of a specified dropdown option.

this.getItem(value)[0].innerHTML获取当前下拉选项的文本值

this.getItem(value)[0].innerHTML to get text value of current dropdown option

这篇关于使用selectize从选定内容获取文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆