[英]CSS Display property issue in Table with JavaScript
There are two buttons in my code. 我的代码中有两个按钮。 one is for display:none and the other is to display Element again at same position. 一个用于显示:无,另一个用于在同一位置再次显示元素。
When I am applying Display:none property through JavaScript on table row ie . 当我在表行上通过JavaScript应用Display:none属性时。 it works perfect. 它完美无缺。
but now I want to return again on click. 但现在我想再次点击返回。 but it's not Displaying on it's accurate position. 但它没有显示它的准确位置。
TABLE 表
<table border="1">
<tr> <td>name</td><td>cell</td> </tr>
<tr id="rw"> <td>Ali</td><td>0341455454</td> </tr>
<tr> <td>irfan</td><td>033435783</td> </tr>
</table>
Buttons 纽扣
<input type="button" value=" click to display none " onclick="Javascript:document.getElementById('rw').style.display='none';" />
<input type="button" value=" click to display back " onclick="Javascript:document.getElementById('rw').style.display='inline';" />
display-inline is not a table element. display-inline不是表元素。 Use 'table-row' instead of 'inline'. 使用'table-row'而不是'inline'。
<input type="button" value=" click to display back " onclick="Javascript:document.getElementById('rw').style.display='table-row';" />
Updated FIDDLE 更新了FIDDLE
Read more about Display options from here 从此处阅读有关显示选项的更多信息
Use table-row instead of inline: 使用表行而不是内联:
<input type="button" value=" click to display none " onclick="Javascript:document.getElementById('rw').style.display='none';" />
<input type="button" value=" click to display back " onclick="Javascript:document.getElementById('rw').style.display='table-row';" />
By default <tr>
elements are display: table-row
, not display: inline
. 默认情况下, <tr>
元素display: table-row
,not display: inline
。
It is displaying incorrectly because you are giving it the wrong display model. 它显示不正确,因为您给它错误的显示模型。
Display:'none' OR display:' ' (empty) using 显示:'无'或显示:''(空)使用
<input type="button" value="none" onclick="Javascript:document.getElementById('rw').style.display='none';" />
<input type="button" value="view" onclick="Javascript:document.getElementById('rw').style.display='';" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.