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>
Your Rating




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
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2019 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer