Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Jquery font size changer not working on wamp

Featured Replies

Hello friends,

 

I  was .. following a simple font size changing tutorial

but everytime i click the bigger or smaller link the paragraphp fonts ... of increase or decrease for an instant and againt returns back to original size

 

here is the code

index.php

<!DOCTYPE html>
<html lang="en-Us">
<head>
<meta charset="UTF-8">
<title>Jquery id selector</title>

 <style>
 
 </style>
</head>
<body>
   Font size:<br>
  <a href="" id="smaller">Smaller<a/>
  <br>
  <a href="" id="bigger">Bigger<a/>
  <p>This is some text</p>
  <p>This is some more text</p>
  
  
  <script type="text/javascript" src ="js/jquery.js"></script> 
  <script type="text/javascript" src ="js/selectors.js"></script> 
 
</body>
</html>

selectors.js

function change_size(element,size)
{
	var current = parseInt(element.css("font-size"));
	if(size == "smaller")
	{
		var new_size = current - 2;
	}
	else if(size == "bigger")
	{
		var new_size = current + 2;
	}
	element.css("font-size",new_size + "px");
}
$("#smaller").click(function(){
	change_size($("p"),"smaller");
});

$("#bigger").click(function(){
	change_size($("p"),"bigger");
});

i am testing this on wamp servere

  • Author

ok i got this fixed

adding # in anchor tags fixed this

<a href="#" id="smaller">Smaller<a/>
  <br>
 <a href="#" id="bigger">Bigger<a/>

 

I'd use a button for this, anchors should only really be used if they are going to update the URL in someway.  You might also want to store the users preference in a cookie or localStorage so it persists across subsequent visits and while navigating your website.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.