jquery - Replace hidden text with correct information on click -
i'm creating online resume , want hide part of personal details until user clicks button show it. i'm hoping prevent spammer's being able personal details easily.
the concept gumtree.com.au do, can seen in image below outside of australia:
my page's html is:
<div class="personal"> <p>042323**** <span id="phone">show number</span></p> </div>
and planning on using jquery remove asterisks, add last 4 digits of number (which going hardcode javascript file).
firstly, best way go doing this? if so, how can remove asterisks , replace them correct details using jquery?
put number in tag -
<p><span id='number'>042323****</span> <span id="phone">show number</span></p>
and can -
var num = 1234; // hard-coded number - last 4 digits $('#phone').on('click',function(){ $('#number').text(function(_,txt){ return txt.replace('****',num); }); });
Comments
Post a Comment