« first day (3102 days earlier)      last day (686 days later) » 

12:08 PM
@TylerH is there a function in pure JavaScript to get the nearest element like when I click on a button than focus on its nearest input . While this can be easily solved by giving class or id but as there are many inputs and buttons. 1 solution is using previous next sibling but when that element is not sibling in that scenario
 
 
1 hour later…
1:31 PM
Also @TylerH how to hide default eye icon in <input type="password">
I found this:
input::-ms-reveal,
      input::-ms-clear {
        display: none;
      }
But not sure it is applicable on all browser . Can you shine light on this too or tell any other way if possible
 
2:04 PM
@Rana You want to use your own icon or you want to prevent users from showing the hidden value?
@Rana Element.closest() but I am not really familiar with it. You can ask about JS in the JS chat room; you'll get better/more knowledgeable answers there
 
 
1 hour later…
3:38 PM
Thanks @TylerH , I am using my own icon but it is shown only when some input is done . That's why I want to hide default icon of the input password
@TylerH I tried in that room but don't get a better answer
Here is the answer :
@Rana actual positioning (and thus getting distances) is hard, really hard.
So there's no direct function and you'll have to rely on iterating the full dom and getting the position/size of each element (very slow).
@Rana a better solution is to use ids and calculate the "correct" id from the button (in generic case using string manipulation, getting its own id and then calculating the would be label id)
 
I think you are right about : .closest()
I can't find any clear question on SO so wasn't sure . Here is a link to MDN : developer.mozilla.org/en-US/docs/Web/API/Element/closest
 

« first day (3102 days earlier)      last day (686 days later) »