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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

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
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
CSS

From novice to tech pro — start learning today.