首页 \ 问答 \ jQuery:按值选择选项元素(jQuery: Selecting option elements by their value)

jQuery:按值选择选项元素(jQuery: Selecting option elements by their value)

如果它们的值为“1”,我想从某些选择框中删除特定选项(所有选项都具有相同的值)。 问题是,我很难将元素过滤到特定值。

目前,我最接近的是

$('.demoClass').find('option:contains(1)').remove();

但有两个问题。 首先,这似乎迭代了选项的(显示的)内容,而不是它的值......其次,它似乎返回true,内容包含该值,而不是该值。 (例如,包含(1)将为(1,10,11,12)返回true ...当我希望它仅为“1”返回true时)

简而言之,我要做的是在类“.demoClass”的所有选择框中找到值为X的时间段选项并删除它们。 任何建议赞赏。


I'd like to remove a specific option from some select boxes (all with the same values) if their value is "1". The problem is, I'm having difficulty filtering elements down to that specific value.

At the moment, the closest I've got is

$('.demoClass').find('option:contains(1)').remove();

but there are two problems. Firstly, this seems to iterate over the (displayed) contents of the option, not its value...and secondly, it seems to return true the contents contain that value, as opposed to being that value. (Eg contains(1) will return true for (1, 10, 11, 12)...when I want it to return true for "1" only)

In short, what I'm looking to do is find the timeslot option with value X inside all select boxes of class ".demoClass" and remove them. Any suggestions appreciated.


原文:https://stackoverflow.com/questions/5643966
更新时间:2023-05-03 17:05

最满意答案

经过多次反复试验,我找到了罪魁祸首。 至少在我的情况下。 对于我的剑道文本框,我设置了最大尺寸。 而不是像999亿这样设置它我将它设置为Decimal.MaxValue和Int32.MaxValue。 Chrome不喜欢这样并发出内存溢出。 有这个的两个部分是:

 <div class="row">
    <div class="col-md-6">
        @Html.LabelFor(i => i.MonataryValue)<br />
        @Html.Kendo().NumericTextBoxFor(i => i.MonataryValue).Decimals(2).Format("c").Placeholder("$ 0.00").Max(Decimal.MaxValue).Min(0).Spinners(false).HtmlAttributes(new { style = "width:100%" })
    </div>
    <div class="col-md-6">
        @Html.LabelFor(i => i.MonataryValueRecovered)<br />
        @Html.Kendo().NumericTextBoxFor(i => i.MonataryValueRecovered).Decimals(2).Format("c").Placeholder("$ 0.00").Max(Decimal.MaxValue).Min(0).Spinners(false).HtmlAttributes(new { style = "width:100%" })
    </div>
</div>

<div class="row">
    <div class="col-md-6">
        <div class="col-md-12">@Html.LabelFor(i => i.Weight)</div>
        <div class="col-md-3">@Html.Kendo().NumericTextBoxFor(i => i.Weight).Decimals(2).Placeholder("0.00").Max(Decimal.MaxValue).Min(0).Spinners(false).HtmlAttributes(new { style = "width:100%" })</div>
        <div class="col-md-9">
            @Html.TextBoxFor(m => m.UnitofWeight, new { @class = "form-control" })
        </div>
    </div>
    <div class="col-md-6">
        @Html.LabelFor(i => i.Quantity)<br />
        @Html.Kendo().NumericTextBoxFor(i => i.Quantity).Decimals(2).Placeholder("0.00").Spinners(false).Max(Int32.MaxValue).Min(0).HtmlAttributes(new { style = "width:100%" })
    </div>
</div>

我已经将它们调整到更小的值,它没有问题,这可能只是一个kendo限制。


So after much trial and error i have found the culprit. At least in my case. For my kendo textboxes i was setting a max size. Instead of setting it so something like 999 billion i set it to Decimal.MaxValue and Int32.MaxValue. Chrome did not like this and issued a memory overflow. the two sections that had this in it were:

 <div class="row">
    <div class="col-md-6">
        @Html.LabelFor(i => i.MonataryValue)<br />
        @Html.Kendo().NumericTextBoxFor(i => i.MonataryValue).Decimals(2).Format("c").Placeholder("$ 0.00").Max(Decimal.MaxValue).Min(0).Spinners(false).HtmlAttributes(new { style = "width:100%" })
    </div>
    <div class="col-md-6">
        @Html.LabelFor(i => i.MonataryValueRecovered)<br />
        @Html.Kendo().NumericTextBoxFor(i => i.MonataryValueRecovered).Decimals(2).Format("c").Placeholder("$ 0.00").Max(Decimal.MaxValue).Min(0).Spinners(false).HtmlAttributes(new { style = "width:100%" })
    </div>
</div>

<div class="row">
    <div class="col-md-6">
        <div class="col-md-12">@Html.LabelFor(i => i.Weight)</div>
        <div class="col-md-3">@Html.Kendo().NumericTextBoxFor(i => i.Weight).Decimals(2).Placeholder("0.00").Max(Decimal.MaxValue).Min(0).Spinners(false).HtmlAttributes(new { style = "width:100%" })</div>
        <div class="col-md-9">
            @Html.TextBoxFor(m => m.UnitofWeight, new { @class = "form-control" })
        </div>
    </div>
    <div class="col-md-6">
        @Html.LabelFor(i => i.Quantity)<br />
        @Html.Kendo().NumericTextBoxFor(i => i.Quantity).Decimals(2).Placeholder("0.00").Spinners(false).Max(Int32.MaxValue).Min(0).HtmlAttributes(new { style = "width:100%" })
    </div>
</div>

I have adjusted them to much smaller values and it comes through without issue, This may just be a kendo limitation.

相关问答

更多
  • 您可以使用IKVM和Mono的提前编译器生成本机代码。 编辑 在这个页面的底部有一个例子。 You could use IKVM and Mono's ahead of time compiler to generate native code. EDIT There is an example at the bottom of this page.
  • 经过多次反复试验,我找到了罪魁祸首。 至少在我的情况下。 对于我的剑道文本框,我设置了最大尺寸。 而不是像999亿这样设置它我将它设置为Decimal.MaxValue和Int32.MaxValue。 Chrome不喜欢这样并发出内存溢出。 有这个的两个部分是:
    @Html.LabelFor(i => i.MonataryValue)
    @Html.Kendo().Numer ...
  • gtk2hs非常活跃......我认为现在宣布wxhaskell的死亡还为时过早。 Hackage说May版本可以用ghc7构建得很好,可能还有其他原因没有更新。 ...当然,除非你正在寻找像葡萄柚一样的更多类似于葡萄柚的网络 ,但是,由于普遍存在使FRP正确的史诗性,所以没有一种方法真正准备好迎接黄金时段。 gtk2hs is very much alive... I think it's too early to announce wxhaskell's demise, yet. Hackage say ...
  • 我可能会使用Spring http调用程序,希望大型弹簧生态系统的支持有所帮助。 它看起来像Hessian和http调用者应该很容易交换。 I'd probably use either Spring http invoker, hoping that the backing by the large spring ecosystem helps. It also looks like Hessian and http invoker should be easily exchangable.
  • 有用? 是。 但... 它在HTML5中被弃用,一些浏览器仍然支持它,我不建议你在你的项目中使用它。 问题 1)它从网络标准中删除,您可能在尝试从新的浏览器访问您的页面时遇到一些问题。 2)这是SEO不友善的。 一个网页应该只有一个网址,但是如果您使用网页,您的网页将包含多个网址(每个网页一个)。 3)如果帧源不可靠,您可能会遇到安全问题。 使用它的网站 JS Bin,JS Fiddle和Codepen就是很好的例子。 It works? Yes. But... It was deprecated in H ...
  • Cg还在开发吗? 是; NVIDIA继续更新Cg并使其与技术保持同步。 这会让它“死”吗? 这是一个主观问题。 Is Cg still being developed? Yes; NVIDIA continues to update Cg and keep it in sync with technology. Does that make it not "dead"? That's a subjective question.
  • 我通过这样做得到它: $ sudo kill -9 $ node app start I got it to work by doing: $ sudo kill -9 $ node app start
  • 替换此代码: insert_query = "INSERT INTO users VALUE ('$fornavn', '$efternavn', '$adresse', '$postnummer', '$city', '$telefonnummer', '$fdag', '$password', '$email')"; 使用此代码: $insert_query = "INSERT INTO users VALUES ('$fornavn', '$efternavn', '$adresse', '$pos ...
  • 如果连接的客户端崩溃或退出,但其主机操作系统和计算机仍在运行,那么其操作系统的TCP堆栈将向您的服务器发送一个FIN数据包,让您的计算机的TCP堆栈知道TCP连接已关闭。 您的Python应用程序将此视为select(),指示客户端的套接字已准备好读取,然后当您在套接字上调用recv()时,recv()将返回0.当发生这种情况时,您应该通过关闭来响应插座。 如果连接客户端的计算机永远不会有机会发送FIN数据包,另一方面(例如,因为有人伸出并将其以太网线或电源线从插槽中拉出),那么您的服务器将无法实现TCP连 ...
  • 处理与任何其他终止线程没有区别。 之前发生的一件事是根据规则(特定的Thread , ThreadGroup ,所有线程)搜索UncaughtExceptionHandler ,但除此之外,接下来是“正常”清理过程。 与“正常”终止相比,当线程被未捕获的异常终止时,没有关于系统资源(取决于Thread实现)或内存问题的具体后果。 The handling is not different than with any other terminated thread. The one thing that ha ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。