シンプルjQuery九宮格

6981 ワード

友达が九宫格を作ると言っているのを闻いて、私も胜手に1つ书いて、完璧を待っています!!
htmlコード:
<input type="button" value="1"/>

<input type="button" value="2"/>

<input type="button" value="3"/><br>

<input type="button" value="4"/>

<input type="button" value="5"/>

<input type="button" value="6"/><br>

<input type="button" value="7"/>

<input type="button" value="8"/>

<input type="button" value="9"/><br>

<input type="text" value=""/>



<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>

<script type="text/javascript">

var items="";

jQuery(function(){

    $("input:button").each(function(index){

        $(this).mouseover(function(){

            if(items.indexOf($('input').eq(index).val())==-1){

                items+=$('input').eq(index).val();

                $('input:text').val(items)

            }

        })

    })

})

</script>