jquery find .html()等于val(); [英] jquery find .html() equal to val();

查看:84
本文介绍了jquery find .html()等于val();的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ajax表单,我需要找到输入的5位数字zip。 - val();

I have an ajax form and I need to locate the 5 digit zip entered. -- val();

var zip = ($("#edit-field-zip-value").val());

提交后,结果将加载到最多10个拉链的表格中。在10个拉链中,需要用jquery标识。

After submit, results are loaded in a table with upto 10 zips. Within the 10 zips, one needs to be identified with jquery.

$(".zip div:html[text=zip]").addClass("equal");

上述行显然不正确。有人可以帮忙吗?如果我的jquery系列无法实现,我会接受另一种更灵活的解决方案。

The above line is obviously incorrect. Can someone help out with here. If it isn't possible with my line of jquery, I am open to another more flexible solution.

ex:

if (zip == tablezip) {
  console.log("hello"); 
}

MARKUP:

<td>
  <div class="zip">
   <div>90042</div>
   <div>90052</div>
   <div>90062</div>
   <div>90072</div>
   <div>90082</div>
  </div>
</td>


推荐答案

正确的jQuery将是,使用 包含

The correct jQuery would be, using contains:

$('.zip div:contains('+zip+')').addClass('equal');

如果您确切需要它,您可以这样做:

If you needed it to be exact, you could do:

$('.zip div').filter(function() {
   return $(this).text() == zip;
}).addClass('equal');

这篇关于jquery find .html()等于val();的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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