Set a flag for the state being toggled
Hi,
Some one made for this code which I wrote:
- $('.js-showHidePassword').on('click',function(e) {
- $(this).html(($(this).html() ===
- '<span class="hidden_clip">click this button to show or hide the password</span><span aria-hidden="true">Hide</span>'
- ? '<span class="hidden_clip">click this button to show or hide the password</span><span aria-hidden="true">Show</span>'
- : '<span class="hidden_clip">click this button to show or hide the password</span><span aria-hidden="true">Hide</span>'));
The following comment:
This needs to be changed. Set a flag for the state being toggled, update it on toggle and compare against the flag. At the moment this is completely coupled to exact markup, which will change. At the very least it will vary depending on t() function return value.
What doe's he mean? How can I change my code to achieve his requirement?
Thanks