JavaScript
Article

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.

No Reader comments

Recommended
Sponsors
Get the latest in JavaScript, once a week, for free.