JS函数不会.show()div

时间:2015-05-21 00:18:33

标签: javascript jquery html css

我从另一个函数调用function。我有一个console.log("test");来确保实际调用我的嵌套函数,它是。 inputs2不是writing我输入的文字。

这是我的外部JS

function iOwners (tempOwnersName) {
    // write to div: indirowners

    console.log("Test");

    $("#ioi").show();

    var inputs2 = $('#inputs2').empty();

    $("#inputs2").show();


    $('#inputs2').append('<p>Owners of ' + tempOwnersName + '</p><br/><br/><form id="div3">Owner Name: <input type="text" id="indirectExecutivesName" name="indirectExecutivesName"/><br/>Owner Customer Number: <input type="text" id="indirectExecutivesECN" name="indirectExecutivesECN" /><br/>Does the Owner have Control over the Entity: Yes: <input type="radio" name="indirectExecutivesControl" value="yes" /> or No: <input type="radio" name="indirectExecutivesControl" value="no" /><br/>What Percent (do not use % symbol) does the Owner own: <input type="text" name="indirectExecutivesPercent" /></form><br/><br/>');

}

我的HTML部分适用:

<div id="inputs2"></div>
<button id="ioi" onclick="return false">Submit</button>

我的CSS文件适用:

#ioi {
    display: none;
}
#inputs2 {
    display: none;
}

我的show / hide功能适用于许多其他部分,但不适用于input2(input2也适用于其他功能,这就是我清空它的原因)

1 个答案:

答案 0 :(得分:0)

似乎无需修改

function iOwners (tempOwnersName) {
    // write to div: indirowners

    console.log("Test");

    $("#ioi").show();

    var inputs2 = $('#inputs2').empty();

    $("#inputs2").show();


    $('#inputs2').append('<p>Owners of ' + tempOwnersName + '</p><br/><br/><form id="div3">Owner Name: <input type="text" id="indirectExecutivesName" name="indirectExecutivesName"/><br/>Owner Customer Number: <input type="text" id="indirectExecutivesECN" name="indirectExecutivesECN" /><br/>Does the Owner have Control over the Entity: Yes: <input type="radio" name="indirectExecutivesControl" value="yes" /> or No: <input type="radio" name="indirectExecutivesControl" value="no" /><br/>What Percent (do not use % symbol) does the Owner own: <input type="text" name="indirectExecutivesPercent" /></form><br/><br/>');

}

iOwners('Hello Kity');
#ioi {
    display: none;
}
#inputs2 {
    display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="inputs2"></div>
<button id="ioi" onclick="return false">Submit</button>