about function call

Discussion in 'JavaScript' started by jonhyhar, Jan 7, 2011.

  1. #1
    hello I'm not good at JS and JQuery :( I have a quick question

    My fuction is
    
    function achele(kodu) {
        var htmla = 'What is your name?' + kodu + ' is your name ?';	
    $('#mydiv').html(htmla);
    }
    
    Code (markup):
    my question is
    how can I call this function?

    I use this but it doesn't work :/

    
    <script>
    achele('john');
    </script>
    
    <div id="mydiv"></div>
    
    Code (markup):
    p.s. I have to use 'mydiv' id
     
    jonhyhar, Jan 7, 2011 IP
    jeremyhowell likes this.
  2. tvoodoo

    tvoodoo Active Member

    Messages:
    239
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    53
    #2
    
    <html>
    <head>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
        <script>
        function achele(kodu) {
            var htmla = 'What is your name? Is your name ' + kodu + ' ?';	
            $('#mydiv').html(htmla);
        }
        
        $(document).ready(function()
    	{
            achele('john');
        });
        </script>
        
    </head>
    
    <body>
    
    <div id="mydiv"></div>
    
    </body>
    </html>
    
    HTML:
     
    tvoodoo, Jan 7, 2011 IP