Eeep, this is one of those questions where I think more information needs to be determined before a proper answer can be given. First off, why are you trying to do this? If the idea is to make an input field 'disabled' then creating a masker like this is never going to work. You also have to think what will happen for screenreaders dealing with this.
Depending on what you're actually trying to achieve, you may have better luck simply styling the input field itself rather than trying to overlay some extra content on top of it that is going to fail the first time someone who uses keyboard navigation tabs through your content.
So yeah, if you could try and explain what the intent behind this is, we might be able to offer a better solution.