Skip to main content

Use jQuery to Change Web Page Phone Number

By Sam Deering

JavaScript

Share:

Free JavaScript Book!

Write powerful, clean and maintainable JavaScript.

RRP $11.95

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.

Related Articles

Sam Deering has 15+ years of programming and website development experience. He was a website consultant at Console, ABC News, Flight Centre, Sapient Nitro, and the QLD Government and runs a tech blog with over 1 million views per month. Currently, Sam is the Founder of Crypto News, Australia.

New books out now!

Learn the basics of programming with the web's most popular language - JavaScript


A practical guide to leading radical innovation and growth.

Integromat Tower Ad