如何通过单击按钮自动单击多个div

时间:2014-11-08 21:18:02

标签: javascript jquery html css

我在页面中有3个横幅。只需单击HTML按钮即可打开所有链接。 (仅使用JQuery / JavaScript)我的html代码是

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title></title>
    <style type="text/css">
        .divBuff { height:2px;}
        .divButn { height:52px; width:150px;}
        .divButn728 { height:92px; width:728px;}
        .divButn300 { height:302px; width:250px;}
        .divButn120 { height:602px; width:120px;}
    </style>
    <script type='text/javascript'><!--        // <![CDATA[
        var OA_zones = {
            'zone_0': 21,
            'zone_1': 27,
            'zone_2': 11,
            'zone_3': 12,
            'zone_4': 13,
            'zone_5': 14,
            'zone_6': 15,
            'zone_7': 16,
            'zone_8': 17,
            'zone_9': 18,
            'zone_txt': 20,

            'zone_7280': 4,
            'zone_7281': 9,
            'zone_7282': 4,
            'zone_7283': 9,
            'zone_7284': 4,
            'zone_7285': 9,
            'zone_7286': 4,

            'zone_3000': 3,
            'zone_3001': 3,
            'zone_3002': 3,
            'zone_3003': 3,
            'zone_3004': 3,
            'zone_3005': 3,
            'zone_3006': 3,




            'zone_1200': 2,
            'zone_1201': 8,
            'zone_1202': 68,
            'zone_1203': 2,
            'zone_1204': 8,
            'zone_1205': 68,
            'zone_1206': 2


        }
// ]]> --></script>
    <script type='text/javascript' src='http://pirsum.funder.co.il/www/delivery/spcjs.php'></script>
    <script src="http://code.jquery.com/jquery-1.11.0.min.js" type="text/javascript"></script>

<script type="text/javascript">

    $(document).ready(function () {
        $('#Submit1').click(function () {
            var divCount = $("div").length;
            alert(divCount);

            for (var did = 0; did <= divCount; did++) {
                var id = $('div').get(did).id;

                function myFunction() {
                    document.getElementById(id).click();
                }

            }
        });

    });
</script>
</head>
<body>
    <input id="Submit1" type="submit" value="submit" />

<div class="divButn">
<script type='text/javascript'><!--    // <![CDATA[
    OA_show('zone_0');
// ]]> --></script>
</div>
<div class="divBuff"> </div>
<div class="divButn">
<script type='text/javascript'><!--    // <![CDATA[
    OA_show('zone_1');
// ]]> --></script>
</div>
<div class="divBuff"></div>
<div class="divButn">
<script type='text/javascript'><!--    // <![CDATA[
    OA_show('zone_2');
// ]]> --></script>
</div>
</body>


</html>

我使用点击功能但不工作可能是因为它在脚本中使用CDATA格式化。请帮忙 仅使用jquery或java脚本

完成

0 个答案:

没有答案