My code is below
<script>
ball1 = "this is ball1";
ball2 = "this is ball2";
ball3 = "this is ball3";
bat = "this is not a ball";
var arr = $("[name^='ball']");
alert(arr.length);
</script>
I want to get all the variables starting with the string 'ball'. How do I do it? The above code gives the arr.length as 0. Is my code correct?