怎么使用jquery获取多个a元素的值

如何使用jquery获取多个a元素的值
html如下:

<div id='div'>
<a href="javascript:void(0)" name="a">百度</a>
<a href="javascript:void(0)" name="a">google</a>
<a href="javascript:void(0)" name="a">msn</a>
<a href="javascript:void(0)" name="a">qq</a>
<a href="javascript:void(0)" name="a">sina</a>
</div>


<div id='divs'>
<a href="javascript:void(0)" name="b">百</a>
<a href="javascript:void(0)" name="b">g</a>
<a href="javascript:void(0)" name="b">m</a>
<a href="javascript:void(0)" name="b">q</a>
<a href="javascript:void(0)" name="b">s</a>
</div>

js是这样写的:

<script type="text/javascript">
var te = new Array();
$("div a").bind("click", function() {
//text=$(this).html();
te[0]=$(this).html();
alert(te[0]);
    //alert($(this).html());//index
});

$("divs a").bind("click", function() {
//text+=$(this).html();
    te[1]=$(this).html();
//alert(text);//index
alert(te[0]+">>>>>>>>>>>>>"+te[1]);

});
</script>

用意是:点击a的时候直接查询,如果再次点击b就同时查询a和b[也就是第一次查询的时候要保存a的条件],

假设再次点击a,则重新查询,checkbox和radio我知道怎么去做,但是a就不知道怎么做了.

之前写了一个小例子,发现可以重复点击[我要的是不重复同一个查询条件],如下:


<a href="javascript:void(0)" onClick="show('&id=1')">123456</a><br />
<a href="javascript:void(0)" onClick="show('&id=2')">1234567</a><br />
<a href="javascript:void(0)" onclick="show('&id=3')">123455878</a><br />
<a href="javascript:void(0)" onclick="show('&id=4')">123456525</a><br />
<a href="javascript:void(0)" onclick="show('&id=5')">1235789452</a><br />
<a href="javascript:void(0)" onclick="show('&id=6')">12589575</a> <a href="javascript:void(0)" onClick="show('&id=1')">123456</a><br />
<a href="javascript:void(0)" onClick="show('&name=2')">1234567</a><br />
<a href="javascript:void(0)" onclick="show('&age=3')">123455878</a><br />
<a href="javascript:void(0)" onclick="show('&sex=4')">123456525</a><br />
<a href="javascript:void(0)" onclick="show('&color=5')">1235789452</a><br />
<a href="javascript:void(0)" onclick="show('&count=6')">12589575</a> <a href="javascript:void(0)" onClick="showe()" >show number</a> <br/>
<a href="javascript:void(0)" onClick="clears()" >clear</a>
<div id="number" style="font-size:20px;margin:20px;"> </div>

js如下:

<script type="text/javascript">
var sk = new Array();
var text = "";
 function show (is)
{
text="";
sk.push(is);

for(var i=0;i<sk.length;i++)
{
text+=sk[i];
}
showe();
}

function showe()
{
document.getElementById("number").innerHTML=text;
}

function clears()
{
document.getElementById("number").innerHTML="";
}

</script>

等大神,谢谢了.
------解决方案--------------------
你的需求应该是点击a之后查询一次,再点击b之后,将a和b的查询关键词拼接再查询,再点击c时再拼接。但是如果再次点击了a则重新查询对吧??

var query="",obj={};
  $(function(){
    $("#div a").on("click",function(){
      var str=$(this).html().trim();
      if(obj.hasOwnProperty(str)){
        query=str;//重新设定查询关键字
        obj={};
      }
      else{
        query+=str;//拼接查询关键字
      }
    });
  });

------解决方案--------------------
你应该是模拟下拉菜单的实现,最终实现数据提交查询

习惯把查询参数 整合到表单中,而模拟的部分 当事件触发的时候,那么只需要设置提交表单相应的参数值即可,最终还是以提交表单为准,而不用去管什么查询条件的拼接,后台只需要接受表单对应的参数即可。