获取Datalist的数据属性(Get data attribute of Datalist)
我将一些隐藏数据加载到datalist中并将其与data属性绑定。
如果选择了一个值,我想获取相应数据属性的值。 这是我的代码:
<input list="browser" id="number"> <datalist id="browser"> <option data-customValue="Abc" value="Firefox">1</option> <option data-customValue="Def" value="Chrome">2</option> <option data-customValue="Ghi" value="Explorer">3</option> </datalist>
$('#number').on('input', function() { var value = $('#browser').val(); alert($('#browsers [value="' + value + '"]').data('customValue')); });
就我而言,我只是将
undefined
作为回应。这是小提琴: https : //jsfiddle.net/bd4rpztk/1/
I load some hidden data into a datalist and bind it with the data attribute.
If a value selected, I want to get the value of the corresponding data attribute. This is my code:
<input list="browser" id="number"> <datalist id="browser"> <option data-customValue="Abc" value="Firefox">1</option> <option data-customValue="Def" value="Chrome">2</option> <option data-customValue="Ghi" value="Explorer">3</option> </datalist>
$('#number').on('input', function() { var value = $('#browser').val(); alert($('#browsers [value="' + value + '"]').data('customValue')); });
In my case, I only get
undefined
as a response.Here is the fiddle: https://jsfiddle.net/bd4rpztk/1/
原文:https://stackoverflow.com/questions/36039492
更新时间:2023-09-15 20:09
最满意答案
你正在寻找的功能是
CoGetApartmentType
。The function you're looking for is
CoGetApartmentType
.
相关问答
更多-
单线程单元问题(Single thread apartment issue)[2022-08-25]
Main(string[] args)真的是你的入口点吗? 也许你有另一个没有参数的Main()重载。 或者另一个类中的其他Main()。 请打开项目属性并查找启动对象。 Is Main(string[] args) really your entry point? Maybe you have another Main() overload with no parameters. Or some other Main() in another class. Please open Project prop ... -
所有线程默认为MTA,除非在线程启动之前调用SetApartmentState 。 如果你仔细想想,该线程不能共享现有线程的单线程公寓。 All threads default to MTAs, unless SetApartmentState is called before the thread is started. If you think about it, the thread can't share the Single Threaded Apartment of an existing th ...
-
你正在寻找的功能是CoGetApartmentType 。 The function you're looking for is CoGetApartmentType.
-
您必须在启动线程之前调用SetApartmentState()。 在任何线程开始运行任何托管代码之前,CL由CLR初始化。 另请注意,您无法在线程池线程上执行此操作,包括BackgroundWorker。 在多个线程上使用Windows通常是一个坏主意。 线程上的窗口与主UI线程上的窗口没有Z顺序关系。 这可能会导致非常棘手的可用性问题。 就像隐藏在主窗口后面的对话框一样。 也没有任务栏按钮,用户永远不会找到它。 不要这样做,使用Control.Invoke()使对话框是其他窗口的模态。 或者更常见的是,仅 ...
-
线程公寓状态(Thread Apartment State)[2023-07-04]
COM有很高的目标。 其中之一是线程是一个很难正确的编程细节,应该由支持库管理。 与.NET非常不同,完全由您来使用以线程安全方式不是线程安全的类。 这通过注册表工作,COM coclass发布ThreadingModel注册表项,说明它支持哪种类型的线程。 到目前为止,大多数人都使用“公寓”,这是一种有点不明确的说法“我不支持多线程”。 这是COM的一个信号,以确保所有的方法都以线程安全的方式被调用。 如果您的程序从工作线程调用方法,那么COM负责将来自worker的调用封送到创建该实例的线程。 从而自动 ... -
发生的事情是COM Marshaller无法编组该物体。 第一个答案:标准编组需要一个类型库。 可能是对象的类型库未正确注册,因此错误。 你是x86还是x64? 尝试使用REGTLB注册库。 第二个答案:如果这不起作用,简单的答案是使用STA公寓类型的线程。 这可能意味着您无法使用BackgroundWorker,但可能必须使用您在完成时销毁的特殊创建的线程。 如果我们谈论三分钟的操作,额外的开销可以忽略不计。 请注意,必须在要使用它的线程上创建对象,并且公寓类型msut与对象的线程模型兼容,以避免编组。 ...
-
你可能需要相应地调整你的配置,下面应该给你一个线索您对exportToWord调用exportToWord是在配置为Threading.ApartmentState.MTA的线程上运行(Backgroundworker线程是Threading.ApartmentState.MTA )。 通常当您访问此方法的控件时,对于datagridview,您将收到Cross-thread operation not valid错误。 但是,此检查仅针对需要控件的Handle属性的此类访问运行; 在这种情况下,您正在从dgv访问不会触发此检查的数据信息。 如果将以下无意 ...
无法设置指定的COM公寓状态ApartmentState.STA(Failed to set the specified COM apartment state ApartmentState.STA)[2022-02-12]
在新线程上调用COM方法并设置该线程的状态: Thread newThread = new Thread(new ThreadStart(MethodToCallCOMMethod)); newThread.SetApartmentState(ApartmentState.STA); newThread.Start(); Call the COM method on a new thread and set that thread's state instead: Thread newT ...无法计算表达式,因为当前线程处于堆栈溢出状态(Cannot evaluate expression because the current thread is in a stack overflow state)[2022-07-24]
我认为你的XAML的这个错误:相关文章
更多- data-config
- (二)solr data import
- 《Big Data Glossary》笔记
- Spring Data Solr教程(翻译)
- 自己封装的一个Solr Data Import Request Handler Scheduler
- 使用Solr Data Import的delta-import功能
- TMF大数据分析指南 Unleashing Business Value in Big Data(一)
- Solr4:配置Data Import,从数据库直接创建索引
- Spring Data: a new perspective of data operations
- The Log: What every software engineer should know about real-time data's unifying abstraction
最新问答
更多- 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
- 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
- OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
- 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
- codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
- 在计算机拍照在哪里进入
- 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
- No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
- 单页应用程序:页面重新加载(Single Page Application: page reload)
- 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
- System.StackOverflow错误(System.StackOverflow error)
- KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- C#类名中允许哪些字符?(What characters are allowed in C# class name?)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 在Angular 5中不是一个函数(is not a function in Angular 5)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- 常见的python rpc和cli接口(Common python rpc and cli interface)
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)