获取带有JQuery问题的属性值(Uncaught TypeError:不能使用'在'运算符中搜索' length' in ..)

时间:2016-05-12 02:45:35

标签: jquery attributes

我正在尝试使用JQuery获取属性值但是我收到的错误是:jquery.min.js:2未捕获的TypeError:不能使用'在'运营商搜索'长度'在PROD

我看到了一些关于将JQuery版本降级到1.10.xx的建议,但是我在所有版本的JQuery中都遇到了这个错误。

你有任何建议吗?

提前致谢..

我的代码如下:

    @property (nonatomic, strong) IBOutlet UICollectionView* collectionView;

1 个答案:

答案 0 :(得分:1)

你可以尝试

<script>
function writeIt() {
    $('input:not([type="button"])').each(function () {
        var testdata = $(this).attr('test');
        //$(this).val(testdata);
        console.log(testdata);
    });

}
</script>

<强>演示

&#13;
&#13;
function writeIt() {
    $('input:not([type="button"])').each(function () {
       var testdata = $(this).attr('test');
       //$(this).val(testdata);
       console.log(testdata);
    });
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input test="PROD" value="2" type="text">
<input test="DEV"  value="3" type="text">
<input type="button" value="Write It" onclick="writeIt()"/>
&#13;
&#13;
&#13;