User Defined functions jQuery

We can create function and use them as per requirment.

Executing on page load


<script>
$(document).ready(function() {
////////////////
my_function=function my_function(str){
$('#d1').html(str);
}
////////////
my_function('Welcome to Plus2net');
/////////////////
})
</script>

function executing on click

<input type=button id=b1 value='Show' onclick="my_function('hi')";>

<script>
$(document).ready(function() {
////////////////
my_function=function my_function(str){
$('#d1').html(str);
}
////////////
})
</script>

Calling User defined Function

<script>
$(document).ready(function() {
////////////////
my_function=function my_function(str){
$('#d1').html(str);
}
////////////
$('#b1').click(function(){
my_function('hi'); // calls another function
})
///////////
})
</script>

Returning Data from Function


<script>
$(document).ready(function() {
////////////////
my_function=function my_function(str){
return str+" I am plus2net ";
}
////////////
$('#b1').click(function(){
str = my_function('hi'); // calls another function
$('#d1').html(str);
})
})
</script>


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com



    Post your comments , suggestion , error , requirements etc here .







    Most Popular JQuery Scripts

    1

    Two dependant list boxes

    2

    Calendar with Date Selection

    3

    Data change by Slider

    4

    Show & Hide element


    JQuery Video Tutorials




    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer