vendredi 7 octobre 2016

how to connect html button to javascript function?

i recently started to do web programming. i got a task that using javascript.

what i'm trying to do is that i type some text in texture and if i press a button, it makes text size changed so

1) type text in textarea

2) press a button

3) a button calls javascript function from javascript file

4) function changes text size and returns it to somewhere(?)

5) size-changed text is displayed in texture

i think i did 1~3 but not 100% sure

this is my html code :

<!DOCTYPE html>
<html xmlns>
<head>
    <title>Pimp My Text!</title>
    <link  href="http://ift.tt/2cWoklz" rel="stylesheet" type="text/css" />


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

</head>

<body>
    <h1>Pimp My Text</h1>
    <div>
        <img  src="http://ift.tt/2dzn06a" alt="Marty Stepp, pimpin' it!" />
    </div>
    <fieldset>
        <legend>Text</legend>
        <textarea rows ="3" cols= "30" id="txt">
        </textarea>

    </fieldset>
    <fieldset>
        <legend>Pimpification</legend>
        <input type="button" value="Bigger pimpin!"  onclick="doFunction();"/
</br>
        <input type="checkbox" name="Bling" />Bling
    </fieldset>

    </body>
</html>

and this is javascript code from .js file:

function doFunction() {
 var txt = document.getElementById("txt").value;
 var result = txt.fontsize(24); 
}




Aucun commentaire:

Enregistrer un commentaire