我需要用class="隐藏第二个表元素;表格";即在id="的形式元素内;您的个人资料";。表是窗体的直接后代。
以下是不起作用的代码:
#your-profile > table.form-table:nth-child(2) {
display: none;
}
我使用进行了测试
#your-profile > table.form-table {
display: none;
}
并且我能够删除class="0"的所有表;表格";。
请注意,此表格来自Wordpress个人资料页。
这是表格:
<form id="your-profile" action="l/wp-admin/profile.php" method="post" novalidate="novalidate">
<input type="hidden" id="_wpnonce" name="_wpnonce" value="8ae1affd7f"><input type="hidden" name="_wp_http_referer" value="/wp-admin/profile.php">
<p>
<input type="hidden" name="from" value="profile">
<input type="hidden" name="checkuser_id" value="36">
</p>
<h2>Personal Options</h2>
<table class="form-table" role="presentation">
<tbody>
<tr class="user-admin-color-wrap">
<th scope="row">Admin Color Scheme</th>
<td>
<fieldset id="color-picker" class="scheme-list">
<legend class="screen-reader-text"><span>Admin Color Scheme</span></legend>
<input type="hidden" id="color-nonce" name="color-nonce" value="f290674286">
<div class="color-option selected">
<input name="admin_color" id="admin_color_fresh" type="radio" value="fresh" class="tog" checked="checked">
<input type="hidden" class="css_url" value="">
<input type="hidden" class="icon_colors" value="{"icons":{"base":"#a0a5aa","focus":"#00a0d2","current":"#fff"}}">
<label for="admin_color_fresh">Default</label>
<table class="color-palette">
<tbody>
<tr>
<td style="background-color: #222"> </td>
<td style="background-color: #333"> </td>
<td style="background-color: #0073aa"> </td>
<td style="background-color: #00a0d2"> </td>
</tr>
</tbody>
</table>
</div>
<div class="color-option ">
<input name="admin_color" id="admin_color_light" type="radio" value="light" class="tog">
<input type="hidden" class="css_url" value="http://aniridia.local/wp-admin/css/colors/light/colors.min.css">
<input type="hidden" class="icon_colors" value="{"icons":{"base":"#999","focus":"#ccc","current":"#ccc"}}">
<label for="admin_color_light">Light</label>
<table class="color-palette">
<tbody>
<tr>
<td style="background-color: #e5e5e5"> </td>
<td style="background-color: #999"> </td>
<td style="background-color: #d64e07"> </td>
<td style="background-color: #04a4cc"> </td>
</tr>
</tbody>
</table>
</div>
<div class="color-option ">
<input name="admin_color" id="admin_color_blue" type="radio" value="blue" class="tog">
<input type="hidden" class="css_url" value="http://aniridia.local/wp-admin/css/colors/blue/colors.min.css">
<input type="hidden" class="icon_colors" value="{"icons":{"base":"#e5f8ff","focus":"#fff","current":"#fff"}}">
<label for="admin_color_blue">Blue</label>
<table class="color-palette">
<tbody>
<tr>
<td style="background-color: #096484"> </td>
<td style="background-color: #4796b3"> </td>
<td style="background-color: #52accc"> </td>
<td style="background-color: #74B6CE"> </td>
</tr>
</tbody>
</table>
</div>
<div class="color-option ">
<input name="admin_color" id="admin_color_coffee" type="radio" value="coffee" class="tog">
<input type="hidden" class="css_url" value="http://aniridia.local/wp-admin/css/colors/coffee/colors.min.css">
<input type="hidden" class="icon_colors" value="{"icons":{"base":"#f3f2f1","focus":"#fff","current":"#fff"}}">
<label for="admin_color_coffee">Coffee</label>
<table class="color-palette">
<tbody>
<tr>
<td style="background-color: #46403c"> </td>
<td style="background-color: #59524c"> </td>
<td style="background-color: #c7a589"> </td>
<td style="background-color: #9ea476"> </td>
</tr>
</tbody>
</table>
</div>
<div class="color-option ">
<input name="admin_color" id="admin_color_ectoplasm" type="radio" value="ectoplasm" class="tog">
<input type="hidden" class="css_url" value="http://aniridia.local/wp-admin/css/colors/ectoplasm/colors.min.css">
<input type="hidden" class="icon_colors" value="{"icons":{"base":"#ece6f6","focus":"#fff","current":"#fff"}}">
<label for="admin_color_ectoplasm">Ectoplasm</label>
<table class="color-palette">
<tbody>
<tr>
<td style="background-color: #413256"> </td>
<td style="background-color: #523f6d"> </td>
<td style="background-color: #a3b745"> </td>
<td style="background-color: #d46f15"> </td>
</tr>
</tbody>
</table>
</div>
<div class="color-option ">
<input name="admin_color" id="admin_color_midnight" type="radio" value="midnight" class="tog">
<input type="hidden" class="css_url" value="http://aniridia.local/wp-admin/css/colors/midnight/colors.min.css">
<input type="hidden" class="icon_colors" value="{"icons":{"base":"#f1f2f3","focus":"#fff","current":"#fff"}}">
<label for="admin_color_midnight">Midnight</label>
<table class="color-palette">
<tbody>
<tr>
<td style="background-color: #25282b"> </td>
<td style="background-color: #363b3f"> </td>
<td style="background-color: #69a8bb"> </td>
<td style="background-color: #e14d43"> </td>
</tr>
</tbody>
</table>
</div>
<div class="color-option ">
<input name="admin_color" id="admin_color_ocean" type="radio" value="ocean" class="tog">
<input type="hidden" class="css_url" value="http://aniridia.local/wp-admin/css/colors/ocean/colors.min.css">
<input type="hidden" class="icon_colors" value="{"icons":{"base":"#f2fcff","focus":"#fff","current":"#fff"}}">
<label for="admin_color_ocean">Ocean</label>
<table class="color-palette">
<tbody>
<tr>
<td style="background-color: #627c83"> </td>
<td style="background-color: #738e96"> </td>
<td style="background-color: #9ebaa0"> </td>
<td style="background-color: #aa9d88"> </td>
</tr>
</tbody>
</table>
</div>
<div class="color-option ">
<input name="admin_color" id="admin_color_sunrise" type="radio" value="sunrise" class="tog">
<input type="hidden" class="css_url" value="http://aniridia.local/wp-admin/css/colors/sunrise/colors.min.css">
<input type="hidden" class="icon_colors" value="{"icons":{"base":"#f3f1f1","focus":"#fff","current":"#fff"}}">
<label for="admin_color_sunrise">Sunrise</label>
<table class="color-palette">
<tbody>
<tr>
<td style="background-color: #b43c38"> </td>
<td style="background-color: #cf4944"> </td>
<td style="background-color: #dd823b"> </td>
<td style="background-color: #ccaf0b"> </td>
</tr>
</tbody>
</table>
</div>
</fieldset>
</td>
</tr>
<tr class="show-admin-bar user-admin-bar-front-wrap">
<th scope="row">Toolbar</th>
<td>
<label for="admin_bar_front">
<input name="admin_bar_front" type="checkbox" id="admin_bar_front" value="1" checked="checked">
Show Toolbar when viewing site </label><br>
</td>
</tr>
</tbody>
</table>
<h2>Name</h2>
<table class="form-table" role="presentation">
<tbody>
<tr class="user-user-login-wrap">
<th><label for="user_login">Username</label></th>
<td><input type="text" name="user_login" id="user_login" value="test" disabled="disabled" class="regular-text"> <span class="description">Usernames cannot be changed.</span></td>
</tr>
<tr class="user-first-name-wrap">
<th><label for="first_name">First Name</label></th>
<td><input type="text" name="first_name" id="first_name" value="" class="regular-text"></td>
</tr>
<tr class="user-last-name-wrap">
<th><label for="last_name">Last Name</label></th>
<td><input type="text" name="last_name" id="last_name" value="" class="regular-text"></td>
</tr>
<tr class="user-nickname-wrap">
<th><label for="nickname">Nickname <span class="description">(required)</span></label></th>
<td><input type="text" name="nickname" id="nickname" value="test" class="regular-text"></td>
</tr>
<tr class="user-display-name-wrap">
<th><label for="display_name">Display name publicly as</label></th>
<td>
<select name="display_name" id="display_name">
<option selected="selected">test</option>
</select>
</td>
</tr>
</tbody>
</table>
<h2>Contact Info</h2>
<table class="form-table" role="presentation">
<tbody>
<tr class="user-email-wrap">
<th><label for="email">Email <span class="description">(required)</span></label></th>
<td>
<input type="email" name="email" id="email" aria-describedby="email-description" value="test@test.com" class="regular-text ltr">
<p class="description" id="email-description">
If you change this, we will send you an email at your new address to confirm it. <strong>The new address will not become active until confirmed.</strong>
</p>
</td>
</tr>
<tr class="user-url-wrap">
<th><label for="url">Website</label></th>
<td><input type="url" name="url" id="url" value="" class="regular-text code"></td>
</tr>
</tbody>
</table>
<h2>About Yourself</h2>
<table class="form-table" role="presentation">
<tbody>
<tr class="user-description-wrap">
<th><label for="description">Biographical Info</label></th>
<td>
<textarea name="description" id="description" rows="5" cols="30"></textarea>
<p class="description">Share a little biographical information to fill out your profile. This may be shown publicly.</p>
</td>
</tr>
<tr class="user-profile-picture">
<th>Profile Picture</th>
<td>
<img alt="" src="http://2.gravatar.com/avatar/b642b4217b34b1e8d3bd915fc65c4452?s=96&d=mm&r=g" srcset="http://2.gravatar.com/avatar/b642b4217b34b1e8d3bd915fc65c4452?s=192&d=mm&r=g 2x" class="avatar avatar-96 photo" height="96" width="96">
<p class="description">
<a href="https://en.gravatar.com/">You can change your profile picture on Gravatar</a>.
</p>
</td>
</tr>
</tbody>
</table>
<h2>Account Management</h2>
<table class="form-table" role="presentation">
<tbody>
<tr id="password" class="user-pass1-wrap">
<th><label for="pass1">New Password</label></th>
<td>
<input class="hidden" value=" "><!-- #24364 workaround -->
<button type="button" class="button wp-generate-pw hide-if-no-js">Generate Password</button>
<div class="wp-pwd hide-if-js" style="display: none;">
<span class="password-input-wrapper">
<input type="password" name="pass1" id="pass1" class="regular-text" value="" autocomplete="off" data-pw="c^aFWr)L*v#HVDNtZU)*bZbL" aria-describedby="pass-strength-result" disabled="">
</span>
<button type="button" class="button wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="Hide password">
<span class="dashicons dashicons-hidden" aria-hidden="true"></span>
<span class="text">Hide</span>
</button>
<button type="button" class="button wp-cancel-pw hide-if-no-js" data-toggle="0" aria-label="Cancel password change">
<span class="dashicons dashicons-no" aria-hidden="true"></span>
<span class="text">Cancel</span>
</button>
<div style="" id="pass-strength-result" aria-live="polite"></div>
</div>
</td>
</tr>
<tr class="user-pass2-wrap hide-if-js" style="display: none;">
<th scope="row"><label for="pass2">Repeat New Password</label></th>
<td>
<input name="pass2" type="password" id="pass2" class="regular-text" value="" autocomplete="off" disabled="">
<p class="description">Type your new password again.</p>
</td>
</tr>
<tr class="pw-weak">
<th>Confirm Password</th>
<td>
<label>
<input type="checkbox" name="pw_weak" class="pw-checkbox">
<span id="pw-weak-text-label">Confirm use of potentially weak password</span>
</label>
</td>
</tr>
<tr class="user-sessions-wrap hide-if-no-js">
<th>Sessions</th>
<td aria-live="assertive">
<div class="destroy-sessions"><button type="button" class="button" id="destroy-sessions">Log Out Everywhere Else</button></div>
<p class="description">
Did you lose your phone or leave your account logged in at a public computer? You can log out everywhere else, and stay logged in here.
</p>
</td>
</tr>
</tbody>
</table>
<input type="hidden" name="action" value="update">
<input type="hidden" name="user_id" id="user_id" value="36">
<p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="Update Profile"></p>
</form>
请使用第n个类型选择器,而不是第n个子项,如下所示。
#your-profile > .form-table:nth-of-type(2) {
display: none;
}