JavaScript
Article
By Sam Deering

Use jQuery to Change Web Page Phone Number

By Sam Deering

Simple jQuery code snippet to change the phone number on a web page. Just say we have a web site with the phone number 999 all over it and we want to change it to 041642×589 (just some random digits) but only for a page called ‘bobs-page’. This is how you do it.

$(document).ready(function() {

	var pageUrl = window.location.href;
	var pageCheck = 'bobs-page';
    var isBobsPage = (pageUrl.indexOf(pageCheck) >= 0);
     //check if it's bobs page
    if (isBobsPage) {
         $('#phone-number').html('041642x589');
    }
	
});

Read here for more info on getting url params.

--ADVERTISEMENT--

Login or Create Account to Comment
Login Create Account
Recommended
Sponsors
Get the most important and interesting stories in tech. Straight to your inbox, daily.