简单jQuery九宫格

时间:2022-05-15
本文章向大家介绍简单jQuery九宫格,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

听朋友说要作个九宫格,我也就随便写一个,等待完善!!

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>