[英]Hide checkbox using css
I have the code, which I get it from inspecting: 我有代码,可以通过检查得到:
<td class=ox-list-pair style>
<input type="CHECKBOX" name="ox_CkSurvey_Sport__xava_selected" value="selected:0" onclick="openxava.onSelectElement('CkSurvey','Sport','null','row=0,viewObject=xava_view',this.checked,'ox_CkSurvey_Sport__0',false,'','border-bottom: 1px solid;','',false,false,0,'xava_tab')">
</td>
I have tried to hide the checkbox but none of them success. 我试图隐藏复选框,但没有一个成功。 My attempts:
我的尝试:
input[type=checkbox].ox_CkSurvey_Sport__xava_selected {
display: none;
}
ox_CkSurvey_Sport__xava_selected {
display: none;
}
.ox_CkSurvey_Sport__xava_selected input[type="checkbox"]{
display:none;
}
Please note that <td>
is valid as it is inside <tr>
as well as <table>
. 请注意,
<td>
是有效的,因为它在<tr>
和<table>
。
Please help me. 请帮我。 Thanks.
谢谢。
You should read up on CSS selectors. 您应该阅读CSS选择器。
https://www.w3schools.com/cssref/css_selectors.asp https://www.w3schools.com/cssref/css_selectors.asp
You are trying to hide the check box with the class "ox_CkSurvey_Sport__xava_selected", but that doesn't exist. 您试图隐藏带有“ ox_CkSurvey_Sport__xava_selected”类的复选框,但是该复选框不存在。
You need to do this: 您需要这样做:
input[type=checkbox][name=ox_CkSurvey_Sport__xava_selected] {
display: none;
}
Is your <td>
valid? 您的
<td>
有效吗? What makes a <td>
valid is: 使
<td>
有效的原因是:
- It must be in a
<tr>
它必须在
<tr>
- That
<tr>
must be in a<table>
该
<tr>
必须在<table>
Technically <tr>
must be in a <tbody>
, <thead>
, or <tfoot>
but the browser will create a <tbody>
by default if there's a <table>
. 从技术上讲,
<tr>
必须位于<tbody>
, <thead>
或<tfoot>
但是如果有<table>
,浏览器将默认创建一个<tbody>
<table>
。
In the demo there's: 在演示中:
a <table>
, <tr>
, <td>
, and your messy checkbox. <table>
, <tr>
, <td>
和您的混乱复选框。
a <td>
and a simple checkbox. <td>
和一个简单的复选框。
Note: The selector is td.ox-list-pair > input[type="checkbox"]
and it successfully hides the messy checkbox and fails to hide the simple checkbox. 注意:选择器是
td.ox-list-pair > input[type="checkbox"]
,它成功隐藏了混乱的复选框,但没有隐藏简单的复选框。 So as you can see that the browser will ignore an invalid <td>
and everything within it. 因此,您可以看到浏览器将忽略无效的
<td>
以及其中的所有内容。 I'm going out on a limb and assume that your <td>
is not inside a <tr>
and/or <table>
. 我出门在外,并假设您的
<td>
不在<tr>
和/或<table>
。
$('td.ox-list-pair > input[type="checkbox"]').css('display', 'none');
b { color: red }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <table> <tr> <td class='ox-list-pair' style> <input type="CHECKBOX" name="ox_CkSurvey_Sport__xava_selected" value="selected:0" onclick="openxava.onSelectElement('CkSurvey','Sport','null','row=0,viewObject=xava_view',this.checked,'ox_CkSurvey_Sport__0',false,'','border-bottom: 1px solid;','',false,false,0,'xava_tab')">I'm in a valid cell </td> </tr> </table> <td class='ox-list-pair'> <input type="CHECKBOX">I'm in an <b>invalid</b> cell </td>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.