Home Web Front-end JS Tutorial jquery method to realize real-time change of web page font size, font background color and color_jquery

jquery method to realize real-time change of web page font size, font background color and color_jquery

May 16, 2016 pm 03:47 PM
jquery font size Web page color

The example in this article describes how jquery can change the font size, font background color and color of the web page in real time. Share it with everyone for your reference. The details are as follows:

Here we use jquery to change the font size, font background color and color in real time. JQUERY makes many things easier. It is indeed a practical little plug-in. Friends who are not familiar with JQ should look at some more examples, such as now From this small example, you can learn a lot of knowledge points.

The operation effect is as shown below:

The specific code is as follows:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title></title>

<script type="text/javascript" src="js/jquery1.3.2.js"></script>

<script type="text/javascript">

$(document).ready(function() {

  $("#fontsize").change(

  function()

  {

   $("p").css({fontSize:this.value});//dom

  }

  )

  // change the font color

  $("#backgroundcolor").change(

  function()

  {

   $("p").css({background:this.value});

  }

  )

  // change the background color

  $("#fontcolor").change(

  function()

  {

   $("p").css({color:this.value});

  }

  )

});

</script>

</head>

<body>

<div id="formstylecontrols">

  <label for="fontsize">字体大小</label>

  <select id="fontsize">

    <option value="12px">小号</option>

    <option value="14px">较小</option>

    <option value="16px" >中号</option>

    <option value="18px">较大</option>

    <option value="24px">大号</option>

  </select>

  <label for="backgroundbackground">背景颜色</label>

  <select id="backgroundcolor">

    <option value="#F4FBFF">默认</option>

    <option value="gray">淡灰</option>

    <option value="red">红色</option>

    <option value="green">绿色</option>

  <option value="yellow">明黄</option>

  </select>

  <label for="fontcolor">字体颜色</label>

  <select id="fontcolor">

    <option value="#000000">黑色</option>

    <option value="#ff0000">红色</option>

    <option value="#006600">绿色</option>

    <option value="#0000ff">蓝色</option>

  <option value="#660000">棕色</option>

  </select>

  <label>

 <input type="submit" id="style" value="保存设置" />

 </label>

</div>

<p>三月初三,春日晴朗</p>

<p>浩浩荡荡的迎亲队伍,转过金陵城的主要街道,再把出尽风头的新皇后冯妙芝送到皇帝选定的洞房柔光殿。贺喜的大臣、亲友已经纷纷告退了,很快,帝后就要携手进入洞房,共度春宵了……</p>

<p>此时此刻,我站在这片泾水和渭水之间的大牧场上,脚下是三块古旧的巨大的石板铺就的小小广场,前面的松柏葱翠里是一座冷冷的尼庵,那就是曾经宠爱过我的君王给我的最后的归宿。</p>

</body>

</script>

</html>

Copy after login

I hope this article will be helpful to everyone’s jquery programming design.

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1653
14
PHP Tutorial
1251
29
C# Tutorial
1224
24
How to send web pages to desktop as shortcut in Edge browser? How to send web pages to desktop as shortcut in Edge browser? Mar 14, 2024 pm 05:22 PM

How to send web pages to the desktop as a shortcut in Edge browser? Many of our users want to display frequently used web pages on the desktop as shortcuts for the convenience of directly opening access pages, but they don’t know how to do it. In response to this problem, the editor of this issue will share the solution with the majority of users. , let’s take a look at the content shared in today’s software tutorial. The shortcut method of sending web pages to the desktop in Edge browser: 1. Open the software and click the "..." button on the page. 2. Select "Install this site as an application" in "Application" from the drop-down menu option. 3. Finally, click it in the pop-up window

What should I do if the images on the webpage cannot be loaded? 6 solutions What should I do if the images on the webpage cannot be loaded? 6 solutions Mar 15, 2024 am 10:30 AM

Some netizens found that when they opened the browser web page, the pictures on the web page could not be loaded for a long time. What happened? I checked that the network is normal, so where is the problem? The editor below will introduce to you six solutions to the problem that web page images cannot be loaded. Web page images cannot be loaded: 1. Internet speed problem The web page cannot display images. It may be because the computer's Internet speed is relatively slow and there are more softwares opened on the computer. And the images we access are relatively large, which may be due to loading timeout. As a result, the picture cannot be displayed. You can turn off the software that consumes more network speed. You can go to the task manager to check. 2. Too many visitors. If the webpage cannot display pictures, it may be because the webpages we visited were visited at the same time.

How to adjust font size in OnePlus_Tutorial on setting font size in OnePlus How to adjust font size in OnePlus_Tutorial on setting font size in OnePlus Mar 23, 2024 am 08:31 AM

1. Open the [Settings] of your phone and click the [Display] option. 2. After entering the display settings page, click the [Font Size] option. 3. Enter the font size setting page and drag the slider left or right to adjust the font size.

How to open php on the web page How to open php on the web page Mar 22, 2024 pm 03:20 PM

Executing PHP code in a web page requires ensuring that the web server supports PHP and is properly configured. PHP can be opened in three ways: * **Server environment:** Place the PHP file in the server root directory and access it through the browser. * **Integrated Development Environment: **Place PHP files in the specified web root directory and access them through the browser. * **Remote Server:** Access PHP files hosted on a remote server via the URL address provided by the server.

How to set font size on Apple mobile phone How to set font size on Apple mobile phone Mar 08, 2024 pm 03:40 PM

The method of setting the font size of Apple mobile phones is relatively simple. Many users do not know how to set it specifically. There are two ways to set it, which are to adjust the font size through mobile phone settings and accessibility functions. How to set the font size on Apple phones? Answer: Set the size through phone settings and accessibility functions 1. The user clicks on the phone settings to enter the display and brightness menu. 2. You can see the text size option in Display and Brightness, click and slide. 3. Slide the slider to set the size of the text. Sliding on the right will make it larger, and sliding on the left will make it smaller. 4. Users can also set the font size through the auxiliary function in Apple mobile phones. 5. In Settings Display and Brightness, continue to slide down to find and click the Accessibility button. 6. Select display

Vivo's new X100 series memory, color exposure: all series start at 12+256GB Vivo's new X100 series memory, color exposure: all series start at 12+256GB May 06, 2024 pm 03:58 PM

According to news on May 6, vivo officially announced today that the new vivoX100 series will be officially released at 19:00 on May 13. It is understood that this conference is expected to release three models, vivoX100s, vivoX100sPro, and vivoX100Ultra, as well as vivo's self-developed imaging brand BlueImage blueprint imaging technology. Digital blogger "Digital Chat Station" also released the official renderings, memory specifications and color matching of these three models today. Among them, X100s adopts a straight screen design, while X100sPro and X100Ultra have curved screen designs. The blogger revealed that vivoX100s comes in four colors: black, titanium, cyan, and white. The memory specifications

jQuery Tips: Quickly modify the text of all a tags on the page jQuery Tips: Quickly modify the text of all a tags on the page Feb 28, 2024 pm 09:06 PM

Title: jQuery Tips: Quickly modify the text of all a tags on the page In web development, we often need to modify and operate elements on the page. When using jQuery, sometimes you need to modify the text content of all a tags in the page at once, which can save time and energy. The following will introduce how to use jQuery to quickly modify the text of all a tags on the page, and give specific code examples. First, we need to introduce the jQuery library file and ensure that the following code is introduced into the page: &lt

Discuz Editor: Powerful web page editing tool Discuz Editor: Powerful web page editing tool Mar 09, 2024 pm 06:06 PM

Discuz Editor: A powerful web page editing tool that requires specific code examples. With the development of the Internet, website construction and content editing have become more and more important. As a common web page editing tool, Discuz editor plays an important role in website construction. It not only provides a wealth of functions and tools, but also helps users edit and publish content more conveniently. In this article, we will introduce the features and usage of the Discuz editor, and provide some specific code examples to help readers better understand and use

See all articles