Disable dropdown item with CSS or JavascriptHow do JavaScript closures work?What is the most efficient way to deep clone an object in JavaScript?How do I remove a property from a JavaScript object?Which equals operator (== vs ===) should be used in JavaScript comparisons?How to disable text selection highlighting?How do I include a JavaScript file in another JavaScript file?What does “use strict” do in JavaScript, and what is the reasoning behind it?How to check whether a string contains a substring in JavaScript?Change an HTML5 input's placeholder color with CSSHow do I remove a particular element from an array in JavaScript?

Name for an item that is out of tolerance or over a threshold

What is the importance of making a variable a constant

How should I ask for a "pint" in countries that use metric?

Tesco's Burger Relish Best Before End date number

Diagram with cylinder shapes and rectangles

Sense of humor in your sci-fi stories

Define functions in a tikzcd diagram

How do I talk to my wife about unrealistic expectations?

How did the IEC decide to create kibibytes?

How do resistors generate different heat if we make the current fixed and changed the voltage and resistance? Notice the flow of charge is constant

Interpretation of non-significant results as "trends"

My professor has told me he will be the corresponding author. Will it hurt my future career?

Passwordless authentication - how and when to invalidate a login code

What does "frozen" mean (e.g. for catcodes)?

Can one block with a protection from color creature?

Can a USB hub be used to access a drive from two devices?

I'm feeling like my character doesn't fit the campaign

Jimmy needs your help!

How can I review my manager, who is fine?

As a supervisor, what feedback would you expect from a PhD who quits?

How many Jimmys can fit?

Does anyone have a method of differentiating informative comments from commented out code?

Examples of fluid (including air) being used to transmit digital data?

Who goes first? Person disembarking bus or the bicycle?



Disable dropdown item with CSS or Javascript


How do JavaScript closures work?What is the most efficient way to deep clone an object in JavaScript?How do I remove a property from a JavaScript object?Which equals operator (== vs ===) should be used in JavaScript comparisons?How to disable text selection highlighting?How do I include a JavaScript file in another JavaScript file?What does “use strict” do in JavaScript, and what is the reasoning behind it?How to check whether a string contains a substring in JavaScript?Change an HTML5 input's placeholder color with CSSHow do I remove a particular element from an array in JavaScript?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








-1















I need to disable, deactivate or at least hide a dropdown item called Private request and I can only use CSS or Javascript to do so.



When I inspect the dropdown item it has the class a.js-dropdown-list. But every item in my dropdown has this class. So I can't just use display: none; because it will hide all options. Is there no more specific ID for every item in the drop down or can I deactivate items with Javascript?



Drop Down looks like this:



drop-down menue



Here the code (1st block is for the picker field, 2nd for the drop-down menue):



<div id="js-organization-picker">
<sd-select class="js-share-with-organisation-picker is-private" data-type="link" data-id="customfield_10203" data-value="38" data-options="[&quot;label&quot;:&quot;Private request&quot;,&quot;styleClass&quot;:&quot;is-private&quot;,&quot;icon&quot;:&quot;locked&quot;,&quot;label&quot;:&quot;Share with Testorganisation&quot;,&quot;value&quot;:38,&quot;icon&quot;:&quot;unlocked&quot;]" resolved="">
<a id="js-customfield_10203-dropdown-trigger" class="aui-dropdown2-trigger aui-button aui-button-link js-trigger customfield_10203-trigger select-dropdown-trigger aui-alignment-target aui-alignment-element-attached-top aui-alignment-element-attached-left aui-alignment-target-attached-bottom aui-alignment-target-attached-left active aui-dropdown2-active aui-alignment-enabled" aria-controls="customfield_10203-dropdown" aria-haspopup="true" role="button" tabindex="0" data-aui-trigger="" data-dropdown2-hide-location="js-customfield_10203-dropdown-container" resolved="" aria-expanded="true" href="#customfield_10203-dropdown">
<span class="aui-icon aui-icon-small aui-iconfont-locked">
: : before
</span> Private request
: : after
</a>
<input name="customfield_10203" type="hidden" class="js-input" value="">
<div id="js-customfield_10203-dropdown-container" class="hidden"></div>
</sd-select>
</div>


<div id="customfield_10203-dropdown" class="aui-dropdown2 filter-dropdown aui-style-default js-filter-dropdown select-dropdown aui-layer aui-alignment-element aui-alignment-side-bottom aui-alignment-snap-left aui-alignment-element-attached-top aui-alignment-element-attached-left aui-alignment-target-attached-bottom aui-alignment-target-attached-left aui-alignment-enabled" role="menu" aria-hidden="false" data-id="customfield_10203" resolved="" style="z-index: 3000; top: 0px; left: 0px; position: absolute; transform: translateX(602px) translateY(918px) translateZ(0px);" data-aui-alignment="bottom auto" data-aui-alignment-static="true">
<div role="application">
<ul class="aui-list">
<li>
<a class="js-dropdown-item " href="#">Private request</a>
</li>
<li></li>
<li>
<a class="js-dropdown-item " href="#" data-value="38">Share with Testorganisation</a>
</li>
<li></li>
</ul>
</div>
</div>









share|improve this question
























  • To be fair the scope here, this is a non-standard dropdown and would typically be an <input> and a <datalist> developer.mozilla.org/en-US/docs/Web/HTML/Element/datalist instead of a link/ <a> anchor tag. A datalist is exactly what what designed for this

    – Mark Schultheiss
    Mar 22 at 12:58












  • Can you please add a reference to the custom dropdown code. It likely has a "selected" type event handler that can be hooked to.

    – Mark Schultheiss
    Mar 22 at 13:06











  • Is it always the first element on the drop-down? does it show all the time?

    – Ignacio Catalina
    Mar 22 at 13:54











  • Curious, why are there empty <li></li>? If just to style CSS might be a better solution.

    – Mark Schultheiss
    Mar 22 at 14:24











  • @MarkSchultheiss I edited the code . I hope it's the right thing i uploaded - after "<a id="js-customfield_10203-dropdown-trigger"... I can find an "event listener" button. Maybe that's what u were searching for?

    – Schmiddi
    Mar 25 at 8:42

















-1















I need to disable, deactivate or at least hide a dropdown item called Private request and I can only use CSS or Javascript to do so.



When I inspect the dropdown item it has the class a.js-dropdown-list. But every item in my dropdown has this class. So I can't just use display: none; because it will hide all options. Is there no more specific ID for every item in the drop down or can I deactivate items with Javascript?



Drop Down looks like this:



drop-down menue



Here the code (1st block is for the picker field, 2nd for the drop-down menue):



<div id="js-organization-picker">
<sd-select class="js-share-with-organisation-picker is-private" data-type="link" data-id="customfield_10203" data-value="38" data-options="[&quot;label&quot;:&quot;Private request&quot;,&quot;styleClass&quot;:&quot;is-private&quot;,&quot;icon&quot;:&quot;locked&quot;,&quot;label&quot;:&quot;Share with Testorganisation&quot;,&quot;value&quot;:38,&quot;icon&quot;:&quot;unlocked&quot;]" resolved="">
<a id="js-customfield_10203-dropdown-trigger" class="aui-dropdown2-trigger aui-button aui-button-link js-trigger customfield_10203-trigger select-dropdown-trigger aui-alignment-target aui-alignment-element-attached-top aui-alignment-element-attached-left aui-alignment-target-attached-bottom aui-alignment-target-attached-left active aui-dropdown2-active aui-alignment-enabled" aria-controls="customfield_10203-dropdown" aria-haspopup="true" role="button" tabindex="0" data-aui-trigger="" data-dropdown2-hide-location="js-customfield_10203-dropdown-container" resolved="" aria-expanded="true" href="#customfield_10203-dropdown">
<span class="aui-icon aui-icon-small aui-iconfont-locked">
: : before
</span> Private request
: : after
</a>
<input name="customfield_10203" type="hidden" class="js-input" value="">
<div id="js-customfield_10203-dropdown-container" class="hidden"></div>
</sd-select>
</div>


<div id="customfield_10203-dropdown" class="aui-dropdown2 filter-dropdown aui-style-default js-filter-dropdown select-dropdown aui-layer aui-alignment-element aui-alignment-side-bottom aui-alignment-snap-left aui-alignment-element-attached-top aui-alignment-element-attached-left aui-alignment-target-attached-bottom aui-alignment-target-attached-left aui-alignment-enabled" role="menu" aria-hidden="false" data-id="customfield_10203" resolved="" style="z-index: 3000; top: 0px; left: 0px; position: absolute; transform: translateX(602px) translateY(918px) translateZ(0px);" data-aui-alignment="bottom auto" data-aui-alignment-static="true">
<div role="application">
<ul class="aui-list">
<li>
<a class="js-dropdown-item " href="#">Private request</a>
</li>
<li></li>
<li>
<a class="js-dropdown-item " href="#" data-value="38">Share with Testorganisation</a>
</li>
<li></li>
</ul>
</div>
</div>









share|improve this question
























  • To be fair the scope here, this is a non-standard dropdown and would typically be an <input> and a <datalist> developer.mozilla.org/en-US/docs/Web/HTML/Element/datalist instead of a link/ <a> anchor tag. A datalist is exactly what what designed for this

    – Mark Schultheiss
    Mar 22 at 12:58












  • Can you please add a reference to the custom dropdown code. It likely has a "selected" type event handler that can be hooked to.

    – Mark Schultheiss
    Mar 22 at 13:06











  • Is it always the first element on the drop-down? does it show all the time?

    – Ignacio Catalina
    Mar 22 at 13:54











  • Curious, why are there empty <li></li>? If just to style CSS might be a better solution.

    – Mark Schultheiss
    Mar 22 at 14:24











  • @MarkSchultheiss I edited the code . I hope it's the right thing i uploaded - after "<a id="js-customfield_10203-dropdown-trigger"... I can find an "event listener" button. Maybe that's what u were searching for?

    – Schmiddi
    Mar 25 at 8:42













-1












-1








-1








I need to disable, deactivate or at least hide a dropdown item called Private request and I can only use CSS or Javascript to do so.



When I inspect the dropdown item it has the class a.js-dropdown-list. But every item in my dropdown has this class. So I can't just use display: none; because it will hide all options. Is there no more specific ID for every item in the drop down or can I deactivate items with Javascript?



Drop Down looks like this:



drop-down menue



Here the code (1st block is for the picker field, 2nd for the drop-down menue):



<div id="js-organization-picker">
<sd-select class="js-share-with-organisation-picker is-private" data-type="link" data-id="customfield_10203" data-value="38" data-options="[&quot;label&quot;:&quot;Private request&quot;,&quot;styleClass&quot;:&quot;is-private&quot;,&quot;icon&quot;:&quot;locked&quot;,&quot;label&quot;:&quot;Share with Testorganisation&quot;,&quot;value&quot;:38,&quot;icon&quot;:&quot;unlocked&quot;]" resolved="">
<a id="js-customfield_10203-dropdown-trigger" class="aui-dropdown2-trigger aui-button aui-button-link js-trigger customfield_10203-trigger select-dropdown-trigger aui-alignment-target aui-alignment-element-attached-top aui-alignment-element-attached-left aui-alignment-target-attached-bottom aui-alignment-target-attached-left active aui-dropdown2-active aui-alignment-enabled" aria-controls="customfield_10203-dropdown" aria-haspopup="true" role="button" tabindex="0" data-aui-trigger="" data-dropdown2-hide-location="js-customfield_10203-dropdown-container" resolved="" aria-expanded="true" href="#customfield_10203-dropdown">
<span class="aui-icon aui-icon-small aui-iconfont-locked">
: : before
</span> Private request
: : after
</a>
<input name="customfield_10203" type="hidden" class="js-input" value="">
<div id="js-customfield_10203-dropdown-container" class="hidden"></div>
</sd-select>
</div>


<div id="customfield_10203-dropdown" class="aui-dropdown2 filter-dropdown aui-style-default js-filter-dropdown select-dropdown aui-layer aui-alignment-element aui-alignment-side-bottom aui-alignment-snap-left aui-alignment-element-attached-top aui-alignment-element-attached-left aui-alignment-target-attached-bottom aui-alignment-target-attached-left aui-alignment-enabled" role="menu" aria-hidden="false" data-id="customfield_10203" resolved="" style="z-index: 3000; top: 0px; left: 0px; position: absolute; transform: translateX(602px) translateY(918px) translateZ(0px);" data-aui-alignment="bottom auto" data-aui-alignment-static="true">
<div role="application">
<ul class="aui-list">
<li>
<a class="js-dropdown-item " href="#">Private request</a>
</li>
<li></li>
<li>
<a class="js-dropdown-item " href="#" data-value="38">Share with Testorganisation</a>
</li>
<li></li>
</ul>
</div>
</div>









share|improve this question
















I need to disable, deactivate or at least hide a dropdown item called Private request and I can only use CSS or Javascript to do so.



When I inspect the dropdown item it has the class a.js-dropdown-list. But every item in my dropdown has this class. So I can't just use display: none; because it will hide all options. Is there no more specific ID for every item in the drop down or can I deactivate items with Javascript?



Drop Down looks like this:



drop-down menue



Here the code (1st block is for the picker field, 2nd for the drop-down menue):



<div id="js-organization-picker">
<sd-select class="js-share-with-organisation-picker is-private" data-type="link" data-id="customfield_10203" data-value="38" data-options="[&quot;label&quot;:&quot;Private request&quot;,&quot;styleClass&quot;:&quot;is-private&quot;,&quot;icon&quot;:&quot;locked&quot;,&quot;label&quot;:&quot;Share with Testorganisation&quot;,&quot;value&quot;:38,&quot;icon&quot;:&quot;unlocked&quot;]" resolved="">
<a id="js-customfield_10203-dropdown-trigger" class="aui-dropdown2-trigger aui-button aui-button-link js-trigger customfield_10203-trigger select-dropdown-trigger aui-alignment-target aui-alignment-element-attached-top aui-alignment-element-attached-left aui-alignment-target-attached-bottom aui-alignment-target-attached-left active aui-dropdown2-active aui-alignment-enabled" aria-controls="customfield_10203-dropdown" aria-haspopup="true" role="button" tabindex="0" data-aui-trigger="" data-dropdown2-hide-location="js-customfield_10203-dropdown-container" resolved="" aria-expanded="true" href="#customfield_10203-dropdown">
<span class="aui-icon aui-icon-small aui-iconfont-locked">
: : before
</span> Private request
: : after
</a>
<input name="customfield_10203" type="hidden" class="js-input" value="">
<div id="js-customfield_10203-dropdown-container" class="hidden"></div>
</sd-select>
</div>


<div id="customfield_10203-dropdown" class="aui-dropdown2 filter-dropdown aui-style-default js-filter-dropdown select-dropdown aui-layer aui-alignment-element aui-alignment-side-bottom aui-alignment-snap-left aui-alignment-element-attached-top aui-alignment-element-attached-left aui-alignment-target-attached-bottom aui-alignment-target-attached-left aui-alignment-enabled" role="menu" aria-hidden="false" data-id="customfield_10203" resolved="" style="z-index: 3000; top: 0px; left: 0px; position: absolute; transform: translateX(602px) translateY(918px) translateZ(0px);" data-aui-alignment="bottom auto" data-aui-alignment-static="true">
<div role="application">
<ul class="aui-list">
<li>
<a class="js-dropdown-item " href="#">Private request</a>
</li>
<li></li>
<li>
<a class="js-dropdown-item " href="#" data-value="38">Share with Testorganisation</a>
</li>
<li></li>
</ul>
</div>
</div>






javascript css drop-down-menu dropdown






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 26 at 0:04









Ignacio Catalina

1974 bronze badges




1974 bronze badges










asked Mar 22 at 12:08









SchmiddiSchmiddi

11 bronze badge




11 bronze badge












  • To be fair the scope here, this is a non-standard dropdown and would typically be an <input> and a <datalist> developer.mozilla.org/en-US/docs/Web/HTML/Element/datalist instead of a link/ <a> anchor tag. A datalist is exactly what what designed for this

    – Mark Schultheiss
    Mar 22 at 12:58












  • Can you please add a reference to the custom dropdown code. It likely has a "selected" type event handler that can be hooked to.

    – Mark Schultheiss
    Mar 22 at 13:06











  • Is it always the first element on the drop-down? does it show all the time?

    – Ignacio Catalina
    Mar 22 at 13:54











  • Curious, why are there empty <li></li>? If just to style CSS might be a better solution.

    – Mark Schultheiss
    Mar 22 at 14:24











  • @MarkSchultheiss I edited the code . I hope it's the right thing i uploaded - after "<a id="js-customfield_10203-dropdown-trigger"... I can find an "event listener" button. Maybe that's what u were searching for?

    – Schmiddi
    Mar 25 at 8:42

















  • To be fair the scope here, this is a non-standard dropdown and would typically be an <input> and a <datalist> developer.mozilla.org/en-US/docs/Web/HTML/Element/datalist instead of a link/ <a> anchor tag. A datalist is exactly what what designed for this

    – Mark Schultheiss
    Mar 22 at 12:58












  • Can you please add a reference to the custom dropdown code. It likely has a "selected" type event handler that can be hooked to.

    – Mark Schultheiss
    Mar 22 at 13:06











  • Is it always the first element on the drop-down? does it show all the time?

    – Ignacio Catalina
    Mar 22 at 13:54











  • Curious, why are there empty <li></li>? If just to style CSS might be a better solution.

    – Mark Schultheiss
    Mar 22 at 14:24











  • @MarkSchultheiss I edited the code . I hope it's the right thing i uploaded - after "<a id="js-customfield_10203-dropdown-trigger"... I can find an "event listener" button. Maybe that's what u were searching for?

    – Schmiddi
    Mar 25 at 8:42
















To be fair the scope here, this is a non-standard dropdown and would typically be an <input> and a <datalist> developer.mozilla.org/en-US/docs/Web/HTML/Element/datalist instead of a link/ <a> anchor tag. A datalist is exactly what what designed for this

– Mark Schultheiss
Mar 22 at 12:58






To be fair the scope here, this is a non-standard dropdown and would typically be an <input> and a <datalist> developer.mozilla.org/en-US/docs/Web/HTML/Element/datalist instead of a link/ <a> anchor tag. A datalist is exactly what what designed for this

– Mark Schultheiss
Mar 22 at 12:58














Can you please add a reference to the custom dropdown code. It likely has a "selected" type event handler that can be hooked to.

– Mark Schultheiss
Mar 22 at 13:06





Can you please add a reference to the custom dropdown code. It likely has a "selected" type event handler that can be hooked to.

– Mark Schultheiss
Mar 22 at 13:06













Is it always the first element on the drop-down? does it show all the time?

– Ignacio Catalina
Mar 22 at 13:54





Is it always the first element on the drop-down? does it show all the time?

– Ignacio Catalina
Mar 22 at 13:54













Curious, why are there empty <li></li>? If just to style CSS might be a better solution.

– Mark Schultheiss
Mar 22 at 14:24





Curious, why are there empty <li></li>? If just to style CSS might be a better solution.

– Mark Schultheiss
Mar 22 at 14:24













@MarkSchultheiss I edited the code . I hope it's the right thing i uploaded - after "<a id="js-customfield_10203-dropdown-trigger"... I can find an "event listener" button. Maybe that's what u were searching for?

– Schmiddi
Mar 25 at 8:42





@MarkSchultheiss I edited the code . I hope it's the right thing i uploaded - after "<a id="js-customfield_10203-dropdown-trigger"... I can find an "event listener" button. Maybe that's what u were searching for?

– Schmiddi
Mar 25 at 8:42












6 Answers
6






active

oldest

votes


















0














E.g. you could give the dropdown item ids to identify them. In HTML this would look like this: <p id="yourIdHere"></p>



You can access this item through Javascript using the document.getElementById() function like this: document.getElementById('yourIdHere').style.display = 'none';




If you can't edit the existing html code, youi have to get the element by it's name/value. This is a bit difficult. You have to iterate through all elements of that type and evaluate each name/value. If you have found the one, you was looking for, you can edit/hide it. You would do so (untested):



var elements = document.getElementsByTagName('div'); //div will be the name of the tag of your elements in the dropdown list 
var length = elements.length;
for (var i=0, item; item = elements[i]; i++)
if(item.value == "Private request") //"Private request" is the name of the element we are looking for
item.style.display = 'none'; //Hide the element







share|improve this answer

























  • Problem is I cannot use any HTML, since I try to manipulate the code of this programm via Addon. I'm also not really firm with programming and certainly not with Jscript. This is the code I have but I can't manipulate with html. Is this even possible then?

    – Schmiddi
    Mar 22 at 12:33











  • Yeah, there is a way. It's a bit tricky, but here you got. I edited my answer.

    – Marvin Klar
    Mar 22 at 12:50











  • item.value will return undefined

    – J. Sadi
    Mar 22 at 13:03


















0














You could loot trough all 'js-dropdown-items', check its innerText for 'Private request' and set its parentNodes display-property to 'none':






var list = document.getElementsByClassName('js-dropdown-item');
for(var i = 0; i < list.length; i++)
if(list[i].innerText === 'Private request') list[i].parentNode.style.display = 'none';

<ul class="aui-list">
<li>
<a class="js-dropdown-item " href="#">Private request</a>
</li>
<li></li>
<li>
<a class="js-dropdown-item " href="#" data-value="38">Share with Testorganisation</a>
</li>
<li></li>
</ul>








share|improve this answer























  • Thanks, I tried the following and it worked so far: #customfield_10203-dropdown div .aui-list li:first-child display: none;. Next step would be to change the preselected red text also to the "Share with organization" item.

    – Schmiddi
    Mar 26 at 10:02



















0














VannillaJS Solution document.querySelectorAll(".aui-list > li")[0].style.display = "none";






share|improve this answer






























    0














    Welcome!



    If I get you right there are plenty of elements with the same ID js-dropdown-list and you want to hide a specific one and there is no additional class for the element and you're not allowed to add specificity to it, let's say by adding of an additional class, you can do the following:



    Grab all elements with this id by:



    let elements = document.querySelectorAll('.js-dropdown-list'); // this is an array of these elements

    let elementToHide = elements[n] // whene n is the number of that element

    //hiding the element
    elementToHide.style.display = 'none';


    Hope that helps!






    share|improve this answer

























    • Since my programming skills are not yet to be developed, I think there are no IDs for my items or I can't find them. I posted a code snipped of that block in my description so I might be wrong.

      – Schmiddi
      Mar 22 at 12:49











    • '#a.somthing' selects an ID 'a' not an element here, and since an ID MUST be unique, this would only select a single element.

      – Mark Schultheiss
      Mar 22 at 12:59












    • @MarkSchultheiss you're correct, I thought letter a is also used as an ID name. Fixed

      – skoch13
      Mar 22 at 13:01











    • Except you did not.

      – Mark Schultheiss
      Mar 22 at 13:36











    • Okay, I got it. So you can solve your issue by the following code: let elements = document.querySelectorAll('.js-dropdown-list'); let elementToHide = elements[0] elementToHide.style.display = 'none';

      – skoch13
      Mar 22 at 14:02


















    0














    NOTE: I believe you will have to actually hide it OR use whatever you are using for this pseudo drop down (there was no reference in the question) to manage the disabled state if it provides that. Reference: https://www.w3.org/TR/2014/REC-html5-20141028/disabled-elements.html



    Get the element by its text and then hide it. Might need the parent but this directly answers the question. Note this could all be wrapped in a function and then called from where you wish.






    function HideByText(elId, findText) 
    let group = document.getElementById(elId).getElementsByClassName('js-dropdown-item');
    let found = Array.prototype.filter.call(group, function(el)
    return el.innerText === findText;
    );
    found.forEach(function(el)
    el.style.display = 'none';
    );
    return found;// in case you need the elements ref.


    let foundFiltered = HideByText('customfield_10203-dropdown', 'Private request');

    <div id="customfield_10203-dropdown" class="aui-dropdown2 filter-dropdown aui-style-default js-filter-dropdown select-dropdown aui-layer aui-alignment-element aui-alignment-side-bottom aui-alignment-snap-left aui-alignment-element-attached-top aui-alignment-element-attached-left aui-alignment-target-attached-bottom aui-alignment-target-attached-left aui-alignment-enabled"
    role="menu" aria-hidden="false" data-id="customfield_10203" resolved="" data-aui-alignment="bottom auto" data-aui-alignment-static="true">
    <div role="application">
    <ul class="aui-list">
    <li>
    <a class="js-dropdown-item " href="#">Private request</a>
    </li>
    <li></li>
    <li>
    <a class="js-dropdown-item " href="#" data-value="38">Share with Testorganisation</a>
    </li>
    <li></li>
    </ul>
    </div>
    </div>





    Alternate for parent would be:



    Change el.style.display = 'none'; to



    if (node.parentElement) 
    el.parentElement.style.display = 'none';






    share|improve this answer

























    • Thanks for reply, I tried the following and it worked for me: #customfield_10203-dropdown div .aui-list li:first-child display: none;. Next step will be to also change the preselected red option to "Share with ...", as in some cases, it is still "Private request".

      – Schmiddi
      Mar 26 at 10:05


















    0














    Have you tried using CSS? Not an ideal solution, but it might be better than using JS for this.



    #js-organization-picker + .aui-dropdown2 .aui-list li:first-child 
    display: none;



    If you need to hide the first 2 elements, you could do something like:



    #js-organization-picker + .aui-dropdown2 .aui-list li:first-child,
    #js-organization-picker + .aui-dropdown2 .aui-list li:first-child + li
    display: none;







    share|improve this answer























    • I tried tthe following: #customfield_10203-dropdown div .aui-list li:first-child display: none; and this worked since there is no more aui.list on the site. Next problem or better solution would be, that the auto selected option would also change. With my option the "Private request" option is just hidden in the dropdown but in some cases still preselected.

      – Schmiddi
      Mar 26 at 10:00














    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55299297%2fdisable-dropdown-item-with-css-or-javascript%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    6 Answers
    6






    active

    oldest

    votes








    6 Answers
    6






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    E.g. you could give the dropdown item ids to identify them. In HTML this would look like this: <p id="yourIdHere"></p>



    You can access this item through Javascript using the document.getElementById() function like this: document.getElementById('yourIdHere').style.display = 'none';




    If you can't edit the existing html code, youi have to get the element by it's name/value. This is a bit difficult. You have to iterate through all elements of that type and evaluate each name/value. If you have found the one, you was looking for, you can edit/hide it. You would do so (untested):



    var elements = document.getElementsByTagName('div'); //div will be the name of the tag of your elements in the dropdown list 
    var length = elements.length;
    for (var i=0, item; item = elements[i]; i++)
    if(item.value == "Private request") //"Private request" is the name of the element we are looking for
    item.style.display = 'none'; //Hide the element







    share|improve this answer

























    • Problem is I cannot use any HTML, since I try to manipulate the code of this programm via Addon. I'm also not really firm with programming and certainly not with Jscript. This is the code I have but I can't manipulate with html. Is this even possible then?

      – Schmiddi
      Mar 22 at 12:33











    • Yeah, there is a way. It's a bit tricky, but here you got. I edited my answer.

      – Marvin Klar
      Mar 22 at 12:50











    • item.value will return undefined

      – J. Sadi
      Mar 22 at 13:03















    0














    E.g. you could give the dropdown item ids to identify them. In HTML this would look like this: <p id="yourIdHere"></p>



    You can access this item through Javascript using the document.getElementById() function like this: document.getElementById('yourIdHere').style.display = 'none';




    If you can't edit the existing html code, youi have to get the element by it's name/value. This is a bit difficult. You have to iterate through all elements of that type and evaluate each name/value. If you have found the one, you was looking for, you can edit/hide it. You would do so (untested):



    var elements = document.getElementsByTagName('div'); //div will be the name of the tag of your elements in the dropdown list 
    var length = elements.length;
    for (var i=0, item; item = elements[i]; i++)
    if(item.value == "Private request") //"Private request" is the name of the element we are looking for
    item.style.display = 'none'; //Hide the element







    share|improve this answer

























    • Problem is I cannot use any HTML, since I try to manipulate the code of this programm via Addon. I'm also not really firm with programming and certainly not with Jscript. This is the code I have but I can't manipulate with html. Is this even possible then?

      – Schmiddi
      Mar 22 at 12:33











    • Yeah, there is a way. It's a bit tricky, but here you got. I edited my answer.

      – Marvin Klar
      Mar 22 at 12:50











    • item.value will return undefined

      – J. Sadi
      Mar 22 at 13:03













    0












    0








    0







    E.g. you could give the dropdown item ids to identify them. In HTML this would look like this: <p id="yourIdHere"></p>



    You can access this item through Javascript using the document.getElementById() function like this: document.getElementById('yourIdHere').style.display = 'none';




    If you can't edit the existing html code, youi have to get the element by it's name/value. This is a bit difficult. You have to iterate through all elements of that type and evaluate each name/value. If you have found the one, you was looking for, you can edit/hide it. You would do so (untested):



    var elements = document.getElementsByTagName('div'); //div will be the name of the tag of your elements in the dropdown list 
    var length = elements.length;
    for (var i=0, item; item = elements[i]; i++)
    if(item.value == "Private request") //"Private request" is the name of the element we are looking for
    item.style.display = 'none'; //Hide the element







    share|improve this answer















    E.g. you could give the dropdown item ids to identify them. In HTML this would look like this: <p id="yourIdHere"></p>



    You can access this item through Javascript using the document.getElementById() function like this: document.getElementById('yourIdHere').style.display = 'none';




    If you can't edit the existing html code, youi have to get the element by it's name/value. This is a bit difficult. You have to iterate through all elements of that type and evaluate each name/value. If you have found the one, you was looking for, you can edit/hide it. You would do so (untested):



    var elements = document.getElementsByTagName('div'); //div will be the name of the tag of your elements in the dropdown list 
    var length = elements.length;
    for (var i=0, item; item = elements[i]; i++)
    if(item.value == "Private request") //"Private request" is the name of the element we are looking for
    item.style.display = 'none'; //Hide the element








    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Mar 22 at 12:49

























    answered Mar 22 at 12:14









    Marvin KlarMarvin Klar

    1,7532 gold badges7 silver badges26 bronze badges




    1,7532 gold badges7 silver badges26 bronze badges












    • Problem is I cannot use any HTML, since I try to manipulate the code of this programm via Addon. I'm also not really firm with programming and certainly not with Jscript. This is the code I have but I can't manipulate with html. Is this even possible then?

      – Schmiddi
      Mar 22 at 12:33











    • Yeah, there is a way. It's a bit tricky, but here you got. I edited my answer.

      – Marvin Klar
      Mar 22 at 12:50











    • item.value will return undefined

      – J. Sadi
      Mar 22 at 13:03

















    • Problem is I cannot use any HTML, since I try to manipulate the code of this programm via Addon. I'm also not really firm with programming and certainly not with Jscript. This is the code I have but I can't manipulate with html. Is this even possible then?

      – Schmiddi
      Mar 22 at 12:33











    • Yeah, there is a way. It's a bit tricky, but here you got. I edited my answer.

      – Marvin Klar
      Mar 22 at 12:50











    • item.value will return undefined

      – J. Sadi
      Mar 22 at 13:03
















    Problem is I cannot use any HTML, since I try to manipulate the code of this programm via Addon. I'm also not really firm with programming and certainly not with Jscript. This is the code I have but I can't manipulate with html. Is this even possible then?

    – Schmiddi
    Mar 22 at 12:33





    Problem is I cannot use any HTML, since I try to manipulate the code of this programm via Addon. I'm also not really firm with programming and certainly not with Jscript. This is the code I have but I can't manipulate with html. Is this even possible then?

    – Schmiddi
    Mar 22 at 12:33













    Yeah, there is a way. It's a bit tricky, but here you got. I edited my answer.

    – Marvin Klar
    Mar 22 at 12:50





    Yeah, there is a way. It's a bit tricky, but here you got. I edited my answer.

    – Marvin Klar
    Mar 22 at 12:50













    item.value will return undefined

    – J. Sadi
    Mar 22 at 13:03





    item.value will return undefined

    – J. Sadi
    Mar 22 at 13:03













    0














    You could loot trough all 'js-dropdown-items', check its innerText for 'Private request' and set its parentNodes display-property to 'none':






    var list = document.getElementsByClassName('js-dropdown-item');
    for(var i = 0; i < list.length; i++)
    if(list[i].innerText === 'Private request') list[i].parentNode.style.display = 'none';

    <ul class="aui-list">
    <li>
    <a class="js-dropdown-item " href="#">Private request</a>
    </li>
    <li></li>
    <li>
    <a class="js-dropdown-item " href="#" data-value="38">Share with Testorganisation</a>
    </li>
    <li></li>
    </ul>








    share|improve this answer























    • Thanks, I tried the following and it worked so far: #customfield_10203-dropdown div .aui-list li:first-child display: none;. Next step would be to change the preselected red text also to the "Share with organization" item.

      – Schmiddi
      Mar 26 at 10:02
















    0














    You could loot trough all 'js-dropdown-items', check its innerText for 'Private request' and set its parentNodes display-property to 'none':






    var list = document.getElementsByClassName('js-dropdown-item');
    for(var i = 0; i < list.length; i++)
    if(list[i].innerText === 'Private request') list[i].parentNode.style.display = 'none';

    <ul class="aui-list">
    <li>
    <a class="js-dropdown-item " href="#">Private request</a>
    </li>
    <li></li>
    <li>
    <a class="js-dropdown-item " href="#" data-value="38">Share with Testorganisation</a>
    </li>
    <li></li>
    </ul>








    share|improve this answer























    • Thanks, I tried the following and it worked so far: #customfield_10203-dropdown div .aui-list li:first-child display: none;. Next step would be to change the preselected red text also to the "Share with organization" item.

      – Schmiddi
      Mar 26 at 10:02














    0












    0








    0







    You could loot trough all 'js-dropdown-items', check its innerText for 'Private request' and set its parentNodes display-property to 'none':






    var list = document.getElementsByClassName('js-dropdown-item');
    for(var i = 0; i < list.length; i++)
    if(list[i].innerText === 'Private request') list[i].parentNode.style.display = 'none';

    <ul class="aui-list">
    <li>
    <a class="js-dropdown-item " href="#">Private request</a>
    </li>
    <li></li>
    <li>
    <a class="js-dropdown-item " href="#" data-value="38">Share with Testorganisation</a>
    </li>
    <li></li>
    </ul>








    share|improve this answer













    You could loot trough all 'js-dropdown-items', check its innerText for 'Private request' and set its parentNodes display-property to 'none':






    var list = document.getElementsByClassName('js-dropdown-item');
    for(var i = 0; i < list.length; i++)
    if(list[i].innerText === 'Private request') list[i].parentNode.style.display = 'none';

    <ul class="aui-list">
    <li>
    <a class="js-dropdown-item " href="#">Private request</a>
    </li>
    <li></li>
    <li>
    <a class="js-dropdown-item " href="#" data-value="38">Share with Testorganisation</a>
    </li>
    <li></li>
    </ul>








    var list = document.getElementsByClassName('js-dropdown-item');
    for(var i = 0; i < list.length; i++)
    if(list[i].innerText === 'Private request') list[i].parentNode.style.display = 'none';

    <ul class="aui-list">
    <li>
    <a class="js-dropdown-item " href="#">Private request</a>
    </li>
    <li></li>
    <li>
    <a class="js-dropdown-item " href="#" data-value="38">Share with Testorganisation</a>
    </li>
    <li></li>
    </ul>





    var list = document.getElementsByClassName('js-dropdown-item');
    for(var i = 0; i < list.length; i++)
    if(list[i].innerText === 'Private request') list[i].parentNode.style.display = 'none';

    <ul class="aui-list">
    <li>
    <a class="js-dropdown-item " href="#">Private request</a>
    </li>
    <li></li>
    <li>
    <a class="js-dropdown-item " href="#" data-value="38">Share with Testorganisation</a>
    </li>
    <li></li>
    </ul>






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Mar 22 at 13:00









    J. SadiJ. Sadi

    2,0101 gold badge10 silver badges24 bronze badges




    2,0101 gold badge10 silver badges24 bronze badges












    • Thanks, I tried the following and it worked so far: #customfield_10203-dropdown div .aui-list li:first-child display: none;. Next step would be to change the preselected red text also to the "Share with organization" item.

      – Schmiddi
      Mar 26 at 10:02


















    • Thanks, I tried the following and it worked so far: #customfield_10203-dropdown div .aui-list li:first-child display: none;. Next step would be to change the preselected red text also to the "Share with organization" item.

      – Schmiddi
      Mar 26 at 10:02

















    Thanks, I tried the following and it worked so far: #customfield_10203-dropdown div .aui-list li:first-child display: none;. Next step would be to change the preselected red text also to the "Share with organization" item.

    – Schmiddi
    Mar 26 at 10:02






    Thanks, I tried the following and it worked so far: #customfield_10203-dropdown div .aui-list li:first-child display: none;. Next step would be to change the preselected red text also to the "Share with organization" item.

    – Schmiddi
    Mar 26 at 10:02












    0














    VannillaJS Solution document.querySelectorAll(".aui-list > li")[0].style.display = "none";






    share|improve this answer



























      0














      VannillaJS Solution document.querySelectorAll(".aui-list > li")[0].style.display = "none";






      share|improve this answer

























        0












        0








        0







        VannillaJS Solution document.querySelectorAll(".aui-list > li")[0].style.display = "none";






        share|improve this answer













        VannillaJS Solution document.querySelectorAll(".aui-list > li")[0].style.display = "none";







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 22 at 13:06









        infamoustreyinfamoustrey

        5927 silver badges14 bronze badges




        5927 silver badges14 bronze badges





















            0














            Welcome!



            If I get you right there are plenty of elements with the same ID js-dropdown-list and you want to hide a specific one and there is no additional class for the element and you're not allowed to add specificity to it, let's say by adding of an additional class, you can do the following:



            Grab all elements with this id by:



            let elements = document.querySelectorAll('.js-dropdown-list'); // this is an array of these elements

            let elementToHide = elements[n] // whene n is the number of that element

            //hiding the element
            elementToHide.style.display = 'none';


            Hope that helps!






            share|improve this answer

























            • Since my programming skills are not yet to be developed, I think there are no IDs for my items or I can't find them. I posted a code snipped of that block in my description so I might be wrong.

              – Schmiddi
              Mar 22 at 12:49











            • '#a.somthing' selects an ID 'a' not an element here, and since an ID MUST be unique, this would only select a single element.

              – Mark Schultheiss
              Mar 22 at 12:59












            • @MarkSchultheiss you're correct, I thought letter a is also used as an ID name. Fixed

              – skoch13
              Mar 22 at 13:01











            • Except you did not.

              – Mark Schultheiss
              Mar 22 at 13:36











            • Okay, I got it. So you can solve your issue by the following code: let elements = document.querySelectorAll('.js-dropdown-list'); let elementToHide = elements[0] elementToHide.style.display = 'none';

              – skoch13
              Mar 22 at 14:02















            0














            Welcome!



            If I get you right there are plenty of elements with the same ID js-dropdown-list and you want to hide a specific one and there is no additional class for the element and you're not allowed to add specificity to it, let's say by adding of an additional class, you can do the following:



            Grab all elements with this id by:



            let elements = document.querySelectorAll('.js-dropdown-list'); // this is an array of these elements

            let elementToHide = elements[n] // whene n is the number of that element

            //hiding the element
            elementToHide.style.display = 'none';


            Hope that helps!






            share|improve this answer

























            • Since my programming skills are not yet to be developed, I think there are no IDs for my items or I can't find them. I posted a code snipped of that block in my description so I might be wrong.

              – Schmiddi
              Mar 22 at 12:49











            • '#a.somthing' selects an ID 'a' not an element here, and since an ID MUST be unique, this would only select a single element.

              – Mark Schultheiss
              Mar 22 at 12:59












            • @MarkSchultheiss you're correct, I thought letter a is also used as an ID name. Fixed

              – skoch13
              Mar 22 at 13:01











            • Except you did not.

              – Mark Schultheiss
              Mar 22 at 13:36











            • Okay, I got it. So you can solve your issue by the following code: let elements = document.querySelectorAll('.js-dropdown-list'); let elementToHide = elements[0] elementToHide.style.display = 'none';

              – skoch13
              Mar 22 at 14:02













            0












            0








            0







            Welcome!



            If I get you right there are plenty of elements with the same ID js-dropdown-list and you want to hide a specific one and there is no additional class for the element and you're not allowed to add specificity to it, let's say by adding of an additional class, you can do the following:



            Grab all elements with this id by:



            let elements = document.querySelectorAll('.js-dropdown-list'); // this is an array of these elements

            let elementToHide = elements[n] // whene n is the number of that element

            //hiding the element
            elementToHide.style.display = 'none';


            Hope that helps!






            share|improve this answer















            Welcome!



            If I get you right there are plenty of elements with the same ID js-dropdown-list and you want to hide a specific one and there is no additional class for the element and you're not allowed to add specificity to it, let's say by adding of an additional class, you can do the following:



            Grab all elements with this id by:



            let elements = document.querySelectorAll('.js-dropdown-list'); // this is an array of these elements

            let elementToHide = elements[n] // whene n is the number of that element

            //hiding the element
            elementToHide.style.display = 'none';


            Hope that helps!







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Mar 22 at 13:47

























            answered Mar 22 at 12:29









            skoch13skoch13

            113 bronze badges




            113 bronze badges












            • Since my programming skills are not yet to be developed, I think there are no IDs for my items or I can't find them. I posted a code snipped of that block in my description so I might be wrong.

              – Schmiddi
              Mar 22 at 12:49











            • '#a.somthing' selects an ID 'a' not an element here, and since an ID MUST be unique, this would only select a single element.

              – Mark Schultheiss
              Mar 22 at 12:59












            • @MarkSchultheiss you're correct, I thought letter a is also used as an ID name. Fixed

              – skoch13
              Mar 22 at 13:01











            • Except you did not.

              – Mark Schultheiss
              Mar 22 at 13:36











            • Okay, I got it. So you can solve your issue by the following code: let elements = document.querySelectorAll('.js-dropdown-list'); let elementToHide = elements[0] elementToHide.style.display = 'none';

              – skoch13
              Mar 22 at 14:02

















            • Since my programming skills are not yet to be developed, I think there are no IDs for my items or I can't find them. I posted a code snipped of that block in my description so I might be wrong.

              – Schmiddi
              Mar 22 at 12:49











            • '#a.somthing' selects an ID 'a' not an element here, and since an ID MUST be unique, this would only select a single element.

              – Mark Schultheiss
              Mar 22 at 12:59












            • @MarkSchultheiss you're correct, I thought letter a is also used as an ID name. Fixed

              – skoch13
              Mar 22 at 13:01











            • Except you did not.

              – Mark Schultheiss
              Mar 22 at 13:36











            • Okay, I got it. So you can solve your issue by the following code: let elements = document.querySelectorAll('.js-dropdown-list'); let elementToHide = elements[0] elementToHide.style.display = 'none';

              – skoch13
              Mar 22 at 14:02
















            Since my programming skills are not yet to be developed, I think there are no IDs for my items or I can't find them. I posted a code snipped of that block in my description so I might be wrong.

            – Schmiddi
            Mar 22 at 12:49





            Since my programming skills are not yet to be developed, I think there are no IDs for my items or I can't find them. I posted a code snipped of that block in my description so I might be wrong.

            – Schmiddi
            Mar 22 at 12:49













            '#a.somthing' selects an ID 'a' not an element here, and since an ID MUST be unique, this would only select a single element.

            – Mark Schultheiss
            Mar 22 at 12:59






            '#a.somthing' selects an ID 'a' not an element here, and since an ID MUST be unique, this would only select a single element.

            – Mark Schultheiss
            Mar 22 at 12:59














            @MarkSchultheiss you're correct, I thought letter a is also used as an ID name. Fixed

            – skoch13
            Mar 22 at 13:01





            @MarkSchultheiss you're correct, I thought letter a is also used as an ID name. Fixed

            – skoch13
            Mar 22 at 13:01













            Except you did not.

            – Mark Schultheiss
            Mar 22 at 13:36





            Except you did not.

            – Mark Schultheiss
            Mar 22 at 13:36













            Okay, I got it. So you can solve your issue by the following code: let elements = document.querySelectorAll('.js-dropdown-list'); let elementToHide = elements[0] elementToHide.style.display = 'none';

            – skoch13
            Mar 22 at 14:02





            Okay, I got it. So you can solve your issue by the following code: let elements = document.querySelectorAll('.js-dropdown-list'); let elementToHide = elements[0] elementToHide.style.display = 'none';

            – skoch13
            Mar 22 at 14:02











            0














            NOTE: I believe you will have to actually hide it OR use whatever you are using for this pseudo drop down (there was no reference in the question) to manage the disabled state if it provides that. Reference: https://www.w3.org/TR/2014/REC-html5-20141028/disabled-elements.html



            Get the element by its text and then hide it. Might need the parent but this directly answers the question. Note this could all be wrapped in a function and then called from where you wish.






            function HideByText(elId, findText) 
            let group = document.getElementById(elId).getElementsByClassName('js-dropdown-item');
            let found = Array.prototype.filter.call(group, function(el)
            return el.innerText === findText;
            );
            found.forEach(function(el)
            el.style.display = 'none';
            );
            return found;// in case you need the elements ref.


            let foundFiltered = HideByText('customfield_10203-dropdown', 'Private request');

            <div id="customfield_10203-dropdown" class="aui-dropdown2 filter-dropdown aui-style-default js-filter-dropdown select-dropdown aui-layer aui-alignment-element aui-alignment-side-bottom aui-alignment-snap-left aui-alignment-element-attached-top aui-alignment-element-attached-left aui-alignment-target-attached-bottom aui-alignment-target-attached-left aui-alignment-enabled"
            role="menu" aria-hidden="false" data-id="customfield_10203" resolved="" data-aui-alignment="bottom auto" data-aui-alignment-static="true">
            <div role="application">
            <ul class="aui-list">
            <li>
            <a class="js-dropdown-item " href="#">Private request</a>
            </li>
            <li></li>
            <li>
            <a class="js-dropdown-item " href="#" data-value="38">Share with Testorganisation</a>
            </li>
            <li></li>
            </ul>
            </div>
            </div>





            Alternate for parent would be:



            Change el.style.display = 'none'; to



            if (node.parentElement) 
            el.parentElement.style.display = 'none';






            share|improve this answer

























            • Thanks for reply, I tried the following and it worked for me: #customfield_10203-dropdown div .aui-list li:first-child display: none;. Next step will be to also change the preselected red option to "Share with ...", as in some cases, it is still "Private request".

              – Schmiddi
              Mar 26 at 10:05















            0














            NOTE: I believe you will have to actually hide it OR use whatever you are using for this pseudo drop down (there was no reference in the question) to manage the disabled state if it provides that. Reference: https://www.w3.org/TR/2014/REC-html5-20141028/disabled-elements.html



            Get the element by its text and then hide it. Might need the parent but this directly answers the question. Note this could all be wrapped in a function and then called from where you wish.






            function HideByText(elId, findText) 
            let group = document.getElementById(elId).getElementsByClassName('js-dropdown-item');
            let found = Array.prototype.filter.call(group, function(el)
            return el.innerText === findText;
            );
            found.forEach(function(el)
            el.style.display = 'none';
            );
            return found;// in case you need the elements ref.


            let foundFiltered = HideByText('customfield_10203-dropdown', 'Private request');

            <div id="customfield_10203-dropdown" class="aui-dropdown2 filter-dropdown aui-style-default js-filter-dropdown select-dropdown aui-layer aui-alignment-element aui-alignment-side-bottom aui-alignment-snap-left aui-alignment-element-attached-top aui-alignment-element-attached-left aui-alignment-target-attached-bottom aui-alignment-target-attached-left aui-alignment-enabled"
            role="menu" aria-hidden="false" data-id="customfield_10203" resolved="" data-aui-alignment="bottom auto" data-aui-alignment-static="true">
            <div role="application">
            <ul class="aui-list">
            <li>
            <a class="js-dropdown-item " href="#">Private request</a>
            </li>
            <li></li>
            <li>
            <a class="js-dropdown-item " href="#" data-value="38">Share with Testorganisation</a>
            </li>
            <li></li>
            </ul>
            </div>
            </div>





            Alternate for parent would be:



            Change el.style.display = 'none'; to



            if (node.parentElement) 
            el.parentElement.style.display = 'none';






            share|improve this answer

























            • Thanks for reply, I tried the following and it worked for me: #customfield_10203-dropdown div .aui-list li:first-child display: none;. Next step will be to also change the preselected red option to "Share with ...", as in some cases, it is still "Private request".

              – Schmiddi
              Mar 26 at 10:05













            0












            0








            0







            NOTE: I believe you will have to actually hide it OR use whatever you are using for this pseudo drop down (there was no reference in the question) to manage the disabled state if it provides that. Reference: https://www.w3.org/TR/2014/REC-html5-20141028/disabled-elements.html



            Get the element by its text and then hide it. Might need the parent but this directly answers the question. Note this could all be wrapped in a function and then called from where you wish.






            function HideByText(elId, findText) 
            let group = document.getElementById(elId).getElementsByClassName('js-dropdown-item');
            let found = Array.prototype.filter.call(group, function(el)
            return el.innerText === findText;
            );
            found.forEach(function(el)
            el.style.display = 'none';
            );
            return found;// in case you need the elements ref.


            let foundFiltered = HideByText('customfield_10203-dropdown', 'Private request');

            <div id="customfield_10203-dropdown" class="aui-dropdown2 filter-dropdown aui-style-default js-filter-dropdown select-dropdown aui-layer aui-alignment-element aui-alignment-side-bottom aui-alignment-snap-left aui-alignment-element-attached-top aui-alignment-element-attached-left aui-alignment-target-attached-bottom aui-alignment-target-attached-left aui-alignment-enabled"
            role="menu" aria-hidden="false" data-id="customfield_10203" resolved="" data-aui-alignment="bottom auto" data-aui-alignment-static="true">
            <div role="application">
            <ul class="aui-list">
            <li>
            <a class="js-dropdown-item " href="#">Private request</a>
            </li>
            <li></li>
            <li>
            <a class="js-dropdown-item " href="#" data-value="38">Share with Testorganisation</a>
            </li>
            <li></li>
            </ul>
            </div>
            </div>





            Alternate for parent would be:



            Change el.style.display = 'none'; to



            if (node.parentElement) 
            el.parentElement.style.display = 'none';






            share|improve this answer















            NOTE: I believe you will have to actually hide it OR use whatever you are using for this pseudo drop down (there was no reference in the question) to manage the disabled state if it provides that. Reference: https://www.w3.org/TR/2014/REC-html5-20141028/disabled-elements.html



            Get the element by its text and then hide it. Might need the parent but this directly answers the question. Note this could all be wrapped in a function and then called from where you wish.






            function HideByText(elId, findText) 
            let group = document.getElementById(elId).getElementsByClassName('js-dropdown-item');
            let found = Array.prototype.filter.call(group, function(el)
            return el.innerText === findText;
            );
            found.forEach(function(el)
            el.style.display = 'none';
            );
            return found;// in case you need the elements ref.


            let foundFiltered = HideByText('customfield_10203-dropdown', 'Private request');

            <div id="customfield_10203-dropdown" class="aui-dropdown2 filter-dropdown aui-style-default js-filter-dropdown select-dropdown aui-layer aui-alignment-element aui-alignment-side-bottom aui-alignment-snap-left aui-alignment-element-attached-top aui-alignment-element-attached-left aui-alignment-target-attached-bottom aui-alignment-target-attached-left aui-alignment-enabled"
            role="menu" aria-hidden="false" data-id="customfield_10203" resolved="" data-aui-alignment="bottom auto" data-aui-alignment-static="true">
            <div role="application">
            <ul class="aui-list">
            <li>
            <a class="js-dropdown-item " href="#">Private request</a>
            </li>
            <li></li>
            <li>
            <a class="js-dropdown-item " href="#" data-value="38">Share with Testorganisation</a>
            </li>
            <li></li>
            </ul>
            </div>
            </div>





            Alternate for parent would be:



            Change el.style.display = 'none'; to



            if (node.parentElement) 
            el.parentElement.style.display = 'none';






            function HideByText(elId, findText) 
            let group = document.getElementById(elId).getElementsByClassName('js-dropdown-item');
            let found = Array.prototype.filter.call(group, function(el)
            return el.innerText === findText;
            );
            found.forEach(function(el)
            el.style.display = 'none';
            );
            return found;// in case you need the elements ref.


            let foundFiltered = HideByText('customfield_10203-dropdown', 'Private request');

            <div id="customfield_10203-dropdown" class="aui-dropdown2 filter-dropdown aui-style-default js-filter-dropdown select-dropdown aui-layer aui-alignment-element aui-alignment-side-bottom aui-alignment-snap-left aui-alignment-element-attached-top aui-alignment-element-attached-left aui-alignment-target-attached-bottom aui-alignment-target-attached-left aui-alignment-enabled"
            role="menu" aria-hidden="false" data-id="customfield_10203" resolved="" data-aui-alignment="bottom auto" data-aui-alignment-static="true">
            <div role="application">
            <ul class="aui-list">
            <li>
            <a class="js-dropdown-item " href="#">Private request</a>
            </li>
            <li></li>
            <li>
            <a class="js-dropdown-item " href="#" data-value="38">Share with Testorganisation</a>
            </li>
            <li></li>
            </ul>
            </div>
            </div>





            function HideByText(elId, findText) 
            let group = document.getElementById(elId).getElementsByClassName('js-dropdown-item');
            let found = Array.prototype.filter.call(group, function(el)
            return el.innerText === findText;
            );
            found.forEach(function(el)
            el.style.display = 'none';
            );
            return found;// in case you need the elements ref.


            let foundFiltered = HideByText('customfield_10203-dropdown', 'Private request');

            <div id="customfield_10203-dropdown" class="aui-dropdown2 filter-dropdown aui-style-default js-filter-dropdown select-dropdown aui-layer aui-alignment-element aui-alignment-side-bottom aui-alignment-snap-left aui-alignment-element-attached-top aui-alignment-element-attached-left aui-alignment-target-attached-bottom aui-alignment-target-attached-left aui-alignment-enabled"
            role="menu" aria-hidden="false" data-id="customfield_10203" resolved="" data-aui-alignment="bottom auto" data-aui-alignment-static="true">
            <div role="application">
            <ul class="aui-list">
            <li>
            <a class="js-dropdown-item " href="#">Private request</a>
            </li>
            <li></li>
            <li>
            <a class="js-dropdown-item " href="#" data-value="38">Share with Testorganisation</a>
            </li>
            <li></li>
            </ul>
            </div>
            </div>






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Mar 25 at 16:02

























            answered Mar 22 at 13:34









            Mark SchultheissMark Schultheiss

            25.2k8 gold badges55 silver badges85 bronze badges




            25.2k8 gold badges55 silver badges85 bronze badges












            • Thanks for reply, I tried the following and it worked for me: #customfield_10203-dropdown div .aui-list li:first-child display: none;. Next step will be to also change the preselected red option to "Share with ...", as in some cases, it is still "Private request".

              – Schmiddi
              Mar 26 at 10:05

















            • Thanks for reply, I tried the following and it worked for me: #customfield_10203-dropdown div .aui-list li:first-child display: none;. Next step will be to also change the preselected red option to "Share with ...", as in some cases, it is still "Private request".

              – Schmiddi
              Mar 26 at 10:05
















            Thanks for reply, I tried the following and it worked for me: #customfield_10203-dropdown div .aui-list li:first-child display: none;. Next step will be to also change the preselected red option to "Share with ...", as in some cases, it is still "Private request".

            – Schmiddi
            Mar 26 at 10:05





            Thanks for reply, I tried the following and it worked for me: #customfield_10203-dropdown div .aui-list li:first-child display: none;. Next step will be to also change the preselected red option to "Share with ...", as in some cases, it is still "Private request".

            – Schmiddi
            Mar 26 at 10:05











            0














            Have you tried using CSS? Not an ideal solution, but it might be better than using JS for this.



            #js-organization-picker + .aui-dropdown2 .aui-list li:first-child 
            display: none;



            If you need to hide the first 2 elements, you could do something like:



            #js-organization-picker + .aui-dropdown2 .aui-list li:first-child,
            #js-organization-picker + .aui-dropdown2 .aui-list li:first-child + li
            display: none;







            share|improve this answer























            • I tried tthe following: #customfield_10203-dropdown div .aui-list li:first-child display: none; and this worked since there is no more aui.list on the site. Next problem or better solution would be, that the auto selected option would also change. With my option the "Private request" option is just hidden in the dropdown but in some cases still preselected.

              – Schmiddi
              Mar 26 at 10:00
















            0














            Have you tried using CSS? Not an ideal solution, but it might be better than using JS for this.



            #js-organization-picker + .aui-dropdown2 .aui-list li:first-child 
            display: none;



            If you need to hide the first 2 elements, you could do something like:



            #js-organization-picker + .aui-dropdown2 .aui-list li:first-child,
            #js-organization-picker + .aui-dropdown2 .aui-list li:first-child + li
            display: none;







            share|improve this answer























            • I tried tthe following: #customfield_10203-dropdown div .aui-list li:first-child display: none; and this worked since there is no more aui.list on the site. Next problem or better solution would be, that the auto selected option would also change. With my option the "Private request" option is just hidden in the dropdown but in some cases still preselected.

              – Schmiddi
              Mar 26 at 10:00














            0












            0








            0







            Have you tried using CSS? Not an ideal solution, but it might be better than using JS for this.



            #js-organization-picker + .aui-dropdown2 .aui-list li:first-child 
            display: none;



            If you need to hide the first 2 elements, you could do something like:



            #js-organization-picker + .aui-dropdown2 .aui-list li:first-child,
            #js-organization-picker + .aui-dropdown2 .aui-list li:first-child + li
            display: none;







            share|improve this answer













            Have you tried using CSS? Not an ideal solution, but it might be better than using JS for this.



            #js-organization-picker + .aui-dropdown2 .aui-list li:first-child 
            display: none;



            If you need to hide the first 2 elements, you could do something like:



            #js-organization-picker + .aui-dropdown2 .aui-list li:first-child,
            #js-organization-picker + .aui-dropdown2 .aui-list li:first-child + li
            display: none;








            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 25 at 21:37









            Ignacio CatalinaIgnacio Catalina

            1974 bronze badges




            1974 bronze badges












            • I tried tthe following: #customfield_10203-dropdown div .aui-list li:first-child display: none; and this worked since there is no more aui.list on the site. Next problem or better solution would be, that the auto selected option would also change. With my option the "Private request" option is just hidden in the dropdown but in some cases still preselected.

              – Schmiddi
              Mar 26 at 10:00


















            • I tried tthe following: #customfield_10203-dropdown div .aui-list li:first-child display: none; and this worked since there is no more aui.list on the site. Next problem or better solution would be, that the auto selected option would also change. With my option the "Private request" option is just hidden in the dropdown but in some cases still preselected.

              – Schmiddi
              Mar 26 at 10:00

















            I tried tthe following: #customfield_10203-dropdown div .aui-list li:first-child display: none; and this worked since there is no more aui.list on the site. Next problem or better solution would be, that the auto selected option would also change. With my option the "Private request" option is just hidden in the dropdown but in some cases still preselected.

            – Schmiddi
            Mar 26 at 10:00






            I tried tthe following: #customfield_10203-dropdown div .aui-list li:first-child display: none; and this worked since there is no more aui.list on the site. Next problem or better solution would be, that the auto selected option would also change. With my option the "Private request" option is just hidden in the dropdown but in some cases still preselected.

            – Schmiddi
            Mar 26 at 10:00


















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55299297%2fdisable-dropdown-item-with-css-or-javascript%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현