jQuery选择where属性=值 [英] jQuery select where attribute = value

查看:111
本文介绍了jQuery选择where属性=值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试选择一个值等于动态值的输入

I am trying to select an input where the value equals a dynamic value

trimmed = jQuery.trim(a);
preSelectedCheckBox = $(this).find("input[value=" + trimmed + "]"); 

该元素存在,但是我一直没有得到任何返回值. ($(preSelectedCheckBox).length = 0)

The element exists but I constantly get no value returned. ($(preSelectedCheckBox).length = 0)

推荐答案

您是否只是遗漏了单引号?

Are you just missing the enclosing single quotes?

trimmed = jQuery.trim(a);
preSelectedCheckBox = $(this).find("input[value='" + trimmed + "']");

这篇关于jQuery选择where属性=值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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