Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 要在按钮/链接上显示特定Div,请单击?_Javascript_Jquery_Html - Fatal编程技术网

Javascript 要在按钮/链接上显示特定Div,请单击?

Javascript 要在按钮/链接上显示特定Div,请单击?,javascript,jquery,html,Javascript,Jquery,Html,我在jsp页面上有多个DIV,我只想在按钮/链接单击事件上加载一个特定的DIV。我不想在页面加载期间使用hide()或display:none隐藏div。jQuery/Javascript代码会有所帮助。谢谢 我想用divid=1和2来实现这一点 <div id=1> <div id=CreBdh> <fieldset style="border : 1px solid #000000">

我在jsp页面上有多个DIV,我只想在按钮/链接单击事件上加载一个特定的DIV。我不想在页面加载期间使用hide()或display:none隐藏div。jQuery/Javascript代码会有所帮助。谢谢

我想用divid=1和2来实现这一点

<div id=1>

            <div id=CreBdh>
             <fieldset style="border : 1px solid #000000">
                              <legend> 
                              <img src="" /> 
             <strong>Step 18:</strong><br>
             </legend><br>
             Please Confirm that this step has been completed.

             <input type="submit" value="Confirm" id="Connckhbx4btn"  onclick="sah1(CreBdh)"/>
             </fieldset>
            </div><br><br>

            <div id=CreBdh1 >
             <fieldset style="border : 1px solid #000000">
                              <legend> 
                              <img src="../images/RightNextArrowDisabled.gif" /> 
                              <strong>Step 19: Create BAR Rate Plan </strong><br>
                              </legend><br>
             Please Confirm that this step has been completed.

             <input type="submit" value="Confirm" id="Connckhbx5btn"  onclick="sah1(CreBdh1)"/>
             </fieldset>
            </div><br><br>


            <div id=CreBdh2>
             <fieldset style="border : 1px solid #000000">
                              <legend> 
                              <img src="" />  
             <strong>Step 20: </strong><br>
             </legend><br>
             Please Confirm that this step has been completed.

             <input type="submit" value="Confirm" id="Connckhbx6btn"  onclick="sah1(CreBdh2)"/>
             </fieldset>
            </div><br><br>


            <div id=CreBdh3>
             <fieldset style="border : 1px solid #000000">
                              <legend> 
                              <img src="../images/RightNextArrowDisabled.gif" /> 
             <strong>Step 21: Create DAILY Rate Plan </strong><br>
             </legend><br>
             Please Confirm that this step has been completed.

             <input type="submit" value="Confirm" id="Connckhbx7btn"  onclick="sah1(CreBdh2)"/>
             </fieldset>
            </div>




</div>


<div id=2>

            <div id=PopData>
            <fieldset style="border : 1px solid #000000">
                              <legend> 
                              <img src="" /> 
                              <strong>Step 22</strong><br>
                              </legend>

             Please Confirm that this step has been completed.

             <input type="submit" value="Confirm" id="Connckhbx8btn"  onclick="sah1(PopData)"/>
             </fieldset>
            </div><br><br>

            <div id=PopData1>
             <fieldset style="border : 1px solid #000000">
                              <legend> 
                              <img src="../images/RightNextArrowDisabled.gif" /> 
             <strong>Step 23</strong><br>
             </legend>
             Please Confirm that this step has been completed.

             <input type="submit" value="Confirm" id="Connckhbx9btn"  onclick="sah1(PopData1)"/>
             </fieldset>
            </div>

</div>

And was using this Jquery to toggle 
var i=0;
var arr=[];

$(document).ready(function(){
    $("div.navItem").each(function(){
        arr[i]=this.id.split("_")[1];
        $(this).bind('click',function(){for(i=2;i<arr.length;i++){$("#"+arr[i]).hide();}$("#"+this.id.split("_")[1]).show();});
        if(i==0){
            i++;
            }else if(i==1){
            i++;
            }
        else{
            $("#"+this.id.split("_")[1]).hide();
            i++;
        }
    });
});

第18步:

请确认此步骤已完成。

步骤19:创建酒吧价格计划

请确认此步骤已完成。

第20步:

请确认此步骤已完成。

步骤21:创建每日费率计划
请确认此步骤已完成。 步骤22
请确认此步骤已完成。

步骤23
请确认此步骤已完成。 使用这个Jquery来切换 var i=0; var-arr=[]; $(文档).ready(函数(){ $(“div.navItem”)。每个(函数(){ arr[i]=此.id.split(“”)[1];
$(this).bind('click',function(){for(i=2;i如果您想在单击按钮或其他操作时将div添加到DOM中,可以使用
.appendChild
——我编写了以下函数,并使用IE10(workplace choice,而不是我的)对其进行了广泛的测试


如您所见,如果要分配样式属性,则需要传递一个“s”作为数组的第三个元素。自定义属性使用“c”,而默认属性则不使用任何内容。如果只传递字符串而不是多维数组,则如果类型为“输入”,则会将字符串视为值,否则会将其视为值“innerHTML。”如果只传递一个数组,也可以使用。

代码在哪里?您已经尝试了什么?
Element.prototype.customAttribute=function(customname, customvalue){
    var z=document.createAttribute(customname);
    z.value=customvalue;
    this.setAttributeNode(z);
    z=null;
}
function toType(obj){
    return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase()
}
function newElement(type, props){
    type=type||"div";
    props=props||[];
    if (props.length==2 && toType(props)=="array" && toType(props[0])!="array"){
        props=[props];
    }
    if (props.length==1 && toType(props[0])=="string" && toType(props)=="array"){
        switch (type){
            case "input":
                props=[["value",props[0]]];
            break;
            default:
                props=[["innerHTML",props[0]]];
            break;
        }
    }
    if (toType(props)=="string"){
        switch (type){
            case "input":
                props=[["value",props]];
            break;
            default:
                props=[["innerHTML",props]];
            break;
        }
    }
    var returnElement=document.createElement(type);
    for (var i=0; i<props.length; i++){
        switch (props[i][2]){
            case "c":
            case 2:
                returnElement.customAttribute(props[i][0],props[i][1]);
            break;
            case "s":
            case 1:
                returnElement.style[props[i][0]]=props[i][1];
            break;
            default:
                returnElement[props[i][0]]=props[i][1];
            break;
        }
    }
    return returnElement;
}
var newDiv=newElement("div",[["innerHTML","default properties (like innerHTML) go in an array with 2 elements."],["backgroundColor","#000000","s"/*s = style*/],["weirdName","Custom attributes have a special third element, 'c' for 'custom'"]]);

document.body.appendChild(newDiv);`