这是我到目前为止,一个div默认可见,另一个隐藏。但是,当我点击按钮时,它们一起出现/消失。我究竟做错了什么?做一个可见的div隐藏和一个不可见的单击按钮时出现?
var hideprofiles = function() {
var mydiv = document.getElementById('newpost');
if (mydiv.style.display === 'block' || mydiv.style.display === '')
mydiv.style.display = 'none';
else
mydiv.style.display = 'block'
}
}
var showprofiles = function() {
var mydiv2 = document.getElementById('NewProfile');
if (mydiv2.style.display === 'block' || mydiv2.style.display === '')
mydiv2.style.display = 'none';
else
mydiv2.style.display = 'block'
}
<div id="newpost2">asdf</div>
<input type="submit" value="btn" onclick="hideprofiles(); showprofiles(); "></input>
<div id="newpost">
<table class="full_width_table" cellspacing="0">
<tr>
<td id="currentprofile">Current Profile:</td>
<td id="selectcurrentprofile">
<select>
<option value="train_manager">Train Manager</option>
</select>
</td>
<td> </td>
<td id="company">Company:</td>
<td id="selectcompany">
<select>
<option value="XC">XC</option>
</select>
</td>
<td> </td>
<td>
<a data-rel="dialog" data-role="button" data-position-to="window" data-mini="false"
data-include-close-btn="false" href="dialogs/new_UserProfile.html" id="createbutton">Create</a>
</td>
</tr>
</table>
</div>
<div id="NewProfile" class="hide_element">
<table class="full_width_table">
编辑,包括一些细节,如被要求
哪里是你'NewProfile'元件? 'hideprofiles()'在哪里?显示更多的代码。 – bbuecherl
你的HTML中的NewProfile和Newpost在哪里? – bbuecherl
用html元素更新 – user3432387