• Register now to get access to thousands of Tutorials, Leaked content, Hot NSFW and much more. Join us as we build and grow the community.

Advertise Here

Advertise Here

Advertise Here

JavaScript - Simple Text Resizer

RemoFloxks

AdWords Master
R Rep
0
0
0
Rep
0
R Vouches
0
0
0
Vouches
0
Posts
93
Likes
159
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 2 1000 XP
In this tutorial we will create a Simple Text Resizer using JavaScript. This code can change the font size to by just dragging the slider button. The code use oninput to initiate a function when the slider has been move in order to dynamically change the text size by modifying the properties of it. Feel free to modify and apply it in your system, this is a user-friendly kind of program

We will be using JavaScript as a server-side scripting language because It gives a greater control of your web page and extend its capability in a modern way approach. It is written in HTML or as an external sourcing to add some necessary features in your website.

Getting started:

First you have to download bootstrap framework, this is the link for the bootstrap that I used for the layout design https://getbootstrap.com/.

The Main Interface

This code contains the interface of the application. To create this just write these block of code inside the text editor and save this as index.html.
  1. <!DOCTYPE html>
  2. <html

    lang

    =

    "en"

    >
  3. <head

    >
  4. <meta

    charset

    =

    "UTF-8"

    name

    =

    "viewport"

    content

    =

    "width=device-width, initial-scale=1"

    /

    >
  5. <link

    rel

    =

    "stylesheet"

    type

    =

    "text/css"

    href

    =

    "css/bootstrap.css"

    /

    >
  6. </

    head

    >
  7. <body

    >
  8. <nav class

    =

    "navbar navbar-default"

    >
  9. <div

    class

    =

    "container-fluid"

    >
  10. <a

    class

    =

    "navbar-brand"

    href

    =

    "https://sourcecodester.com"

    >

    Sourcecodester</

    a

    >
  11. </

    div

    >
  12. </

    nav>
  13. <div

    class

    =

    "col-md-3"

    ></

    div

    >
  14. <div

    class

    =

    "col-md-6 well"

    >
  15. <h3

    class

    =

    "text-primary"

    >

    JavaScript - Simple Text Resizer</

    h3

    >
  16. <hr

    style

    =

    "border-top:1px dotted #ccc;"

    /

    >
  17. <div

    class

    =

    "col-md-2"

    ></

    div

    >
  18. <div

    class

    =

    "col-md-8"

    >
  19. <center

    ><h2

    class

    =

    "text-success"

    id

    =

    "result"

    >

    SOURCECODESTER</

    h2

    ></

    center

    >
  20. <br

    /

    >
  21. <div

    style

    =

    "border:1px solid #000; padding:10px; border-radius:12px;"

    >
  22. <input

    type

    =

    "range"

    min=

    "0"

    max=

    "50"

    value

    =

    "12"

    oninput=

    "resizeText(this.value);"

    /

    >
  23. </

    div

    >
  24. <br

    /

    >
  25. <div

    class

    =

    "form-inline"

    >
  26. <label

    >

    Value</

    label

    >
  27. <input

    type

    =

    "text"

    size

    =

    "1"

    id

    =

    "display"

    class

    =

    "form-control"

    disabled

    =

    "disabled"

    /

    >
  28. </

    div

    >
  29. </

    div

    >
  30. </

    div

    >
  31. <script

    src

    =

    "js/script.js"

    ></

    script

    >
  32. </

    body

    >
  33. </

    html

    >

Creating the Script

This code contains the script of the application. This code will dynamically change the text size when the slider is moved. To do this just copy and write these block of codes inside the text editor, then save it as script.js inside the js folder.
  1. document.getElementById

    (

    "display"

    )

    .value

    =

    "12px"

    ;
  2. document.getElementById

    (

    "result"

    )

    .style

    .fontSize

    =

    val+

    "px"

    ;
  3. function

    resizeText(

    val)

    {
  4. document.getElementById

    (

    "display"

    )

    .value

    =

    val+

    "px"

    ;
  5. document.getElementById

    (

    "result"

    )

    .style

    .fontSize

    =

    val+

    "px"

    ;
  6. }

There you have it we successfully created a Simple Text Resizer using JavaScript. I hope that this simple tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site. Enjoy Coding!


Download
You must upgrade your account or reply in the thread to view the hidden content.
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

452,500

351,032

351,042

Top