CSS help

Hi,

I need some help with a CSS selector to hide a particular element. Please see my html below. What I would like to do ideally is to hide the second td element of the tr with id = OriginalCopyRightsIncluded~Disable. so , in this case, I want hide the text "yes". Can anyone help me with the css for this? please note that I dont want to hide every single element that has "ms-formbody as the class.

<tr id="OriginalCopyRightsIncluded~Disable" unselectable="off">
  <td class="ms-formlabel" nowrap="true" valign="top" style="width: 363px; white-space: nowrap;">
    <h3 class="ms-standardheader" id="OriginalCopyRightsIncluded">
      <nobr>C-Original copyright notices requirement</nobr>
    </h3>
  </td>
  <td class="ms-formbody" valign="top">Yes</td>
</tr>

Open in new window

Please help.
TechsavyAsked:
Who is Participating?
 
Brandon LyonSenior Frontend DeveloperCommented:
Sorry I missed a comment. Yes you can use the title attribute. For that the selector would be:

select[title=^"C-Original"] {}

Open in new window

0
 
Brandon LyonSenior Frontend DeveloperCommented:
Assuming I understand the question correctly, try this selector
#OriginalCopyRightsIncluded~Disable td:nth-of-type(2) {}

Open in new window

0
 
TechsavyAuthor Commented:
Hi Brandon,

Thank you. But unfortunately, it didn't work.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
Brandon LyonSenior Frontend DeveloperCommented:
#OriginalCopyRightsIncluded~Disable does not appear to be a valid id. Try changing the ~ to a - or some other character.

https://codepen.io/anon/pen/WXGNVX
0
 
TechsavyAuthor Commented:
Hi Brandon,

That it the Id that I am seeing in the browser when I inspect the element.

Are we missing any syntax in the selector?
0
 
Brandon LyonSenior Frontend DeveloperCommented:
It would be easiest to troubleshoot if we had access to the page. As it is I'm recommending fixes based on speculation. You can see from the link I provided that if we use the ~ then the selector will not work because that ID is not valid markup (see this link for more details on what are valid ID names)
0
 
TechsavyAuthor Commented:
Ok, if I remove the Disable on the field property, this is what I see in the HTML: Now, I need to hide the "select" element which is the dropdown control I am trying to hide.

The element that I like to hide is the select element with the title C-Original copyright notices requirement



<tr id="OriginalCopyRightsIncluded~Show" unselectable="off">
  <td class="ms-formlabel" nowrap="true" valign="top" style="width: 421px; white-space: nowrap;">
    <h3 class="ms-standardheader" id="OriginalCopyRightsIncluded">
      <nobr>C-Original copyright notices requirement</nobr>
    </h3>
  </td>
  <td class="ms-formbody" valign="top">
    <span dir="none">
      <select title="C-Original copyright notices requirement" class="ms-RadioText" id="OriginalCopyRightsIncluded_80a21860-7b76-4b23-9c49-72316eaf7f40_$DropDownChoice">
        <option selected="selected" value="Yes">Yes</option><option value="No">No</option>
        <option value="N/A">N/A</option>
      </select>
      <br>
    </span>
  </td>
</tr>

Open in new window


Thank you for your help.
0
 
Brandon LyonSenior Frontend DeveloperCommented:
The disable is not the issue. The tilde character ~ is the issue. You will also run into similar issues with the $ sign inside of the select ID.
0
 
TechsavyAuthor Commented:
Not sure how to get rid of those characters. Those are being generated by server controls. I can only work on the html that is being rendered on the page.
0
 
TechsavyAuthor Commented:
Can we use "title" attribute on the select element to hide the select element?
0
 
Brandon LyonSenior Frontend DeveloperCommented:
You can try the selector
tr[id^="OriginalCopyRightsIncluded"] td:nth-child(2) {}

Open in new window

The caveat is that the second td tag of any tr with an ID which starts with the the string OriginalCopyRightsIncluded will be impacted (both show and disable).
0
 
TechsavyAuthor Commented:
Very nice..Thank you. This worked perfectly.
1
 
Julian HansenCommented:
Code tags added @Techsavy - code tags make your post easier to read and refer to. To add code tags highlight your code snippet and click the CODE Button in the toolbar.
It also helps to format your code nicely so that it is easy to read - I have done both for you in the above posts.

Just for interest (no points please) here are some other styles that will achieve the above
tr[id^="OriginalCopyRightsIncluded"] td span[dir="none"] {
	display: none;
}
tr[id^="OriginalCopyRightsIncluded"] td span[dir="none"] select {
	display: none;
}
tr[id^="OriginalCopyRightsIncluded"] td:last-child select {
	display: none;
}

Open in new window

Edit and if you need to keep the ~ in the name then you could use this
#OriginalCopyRightsIncluded\~Show td:last-child select {
	display: none;
}

Open in new window

0
 
Brandon LyonSenior Frontend DeveloperCommented:
The author was provided with a satisfactory solution.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.