javascript - 如何使用这个 jquery-editable-select 插件检测一个元素是否被选中并提醒它的值

标签 javascript jquery html css

我从 here 得到了一个 jquery-editable-select 插件

它不能像普通的 select>option> 标签那样工作。我尝试添加许多不同的 eventListeners,但仍然没有成功。基本上,我想在选择其中一个选项时提醒所选值,并在用户决定将其输入文本字段时提醒文本值。

<select id="editable-select">
<option>Alfa Romeo</option>
<option>Audi</option>
<option>BMW</option>
<option>Citroen</option>
</select>

$('#editable-select').editableSelect();

在测试之前,请在 src 文件夹下包含插件 js 和 css 文件。

它应该看起来像这样。 enter image description here

插件将原始 HTML 转换为此。 enter image description here 非常感谢!

最佳答案

插件有一个监听器

监听变化

  $('#select')
        .editableSelect()
        .on('select.editable-select', function (e, li) {
            $('#last-selected').html(
                li.val() + '. ' + li.text()
            );
        });

jQuery Editable Select Demo

关于javascript - 如何使用这个 jquery-editable-select 插件检测一个元素是否被选中并提醒它的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45787143/

相关文章:

jquery - fullcalendar.formatdate 不起作用

jquery - 使用 prop( ) 按值获取 jQuery 选择选项

javascript - Javascript 中的单独 url/链接

javascript - 在 ag-grid 中显示嵌套的 json

jquery - 将光标更改为圆形?

javascript - 检测浏览器的 native 日期/时间选择器

php - 你能为表格中的一行设置一个值吗?

javascript - 在将图像附加到 div 之前使用 jQuery 调整图像大小

javascript - 将Python字典转换为不带字符串键的JSON对象

javascript - html javascript中的无限滚动