我在表中动态创建下拉列表,并试图获取触发事件的下拉列表的索引,如下所示:
$(".template").on('change', '.dataTypes', function () {
var selectedDatatype = $(this).find(":selected").val();
var ix = $(this).index(); // get this index
$.ajax({
type: "GET",
url: "http:/
我有一个基本的下拉按钮功能,这些按钮通常通过AJAX加载。其基本思想是单击按钮,在下拉内容上切换可见性。这部分起作用了。但我也希望在点击页面其他地方时,下拉内容消失。以下是代码:
$(document).on({
click: function() {
var contentHolder = $(this).siblings("[class^=holder_dropdown]");
if ($(contentHolder).is(":visible")) {
// hide drop
我有大约25个下拉列表,不想加载所有这些下拉列表,除非用户单击它们。我只想在用户实际单击下拉列表时加载下拉列表,因为每个下拉列表都绑定到API调用。
我有一个bug,下拉列表只有在第二次单击之后才会填充,而不是第一次单击。变量有数据,但是UI没有反映这一点。
有人有什么想法吗?如下所示:
tr.find("select").click(function () {
if ($(this).children().length <= 1) { // checking no of options; first one is default
var f