开发者

Arrays in jQuery

开发者 https://www.devze.com 2023-02-05 09:47 出处:网络
How开发者_Python百科 can I use arrays in jQuery? I only want to use numbers 1,2,3,4,5 in a textbox, but how can I set the array and retrieve it?

How开发者_Python百科 can I use arrays in jQuery?

I only want to use numbers 1,2,3,4,5 in a textbox, but how can I set the array and retrieve it?

e.g. if I'm using d.charAt(1) == "1" it is only 1 number, I want to be able to check for 1 or 2 or 3 or 4 or 5 to use the same index. I know I can use ||, but what if I were trying to check for 100 numbers?

Can anyone help me?


To restrict input in a textbox to numbers only I've used jquery.numeric plugin.

$(document).ready(function(){
    $(".numeric").numeric();
});

You can use this with textareas also!


use $.inArray()

0

精彩评论

暂无评论...
验证码 换一张
取 消