Click here to Skip to main content
15,918,808 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi,

I have created a function, function test(){/*some operation*/} in javascript.

I want to bind this function for click event using bind function in jquery

How can i do this?
Posted
Updated 13-Dec-10 22:30pm
v2
Comments
Dalek Dave 14-Dec-10 4:30am    
Edited for Readability.

Thank you for your question. You can follow the bellow code.
C#
function test(){/*some operation*/}

//btnSave is your button.
$('#btnSave').click(function() {
  test();
});

$('#btnYourButton').bind('click', function() {
  test();
});


Thanks,
Mamun
 
Share this answer
 
v3
Comments
niravsahayata 14-Dec-10 5:44am    
hey i know the click event but
i want to bind using this method..
$('#btnsave').bind("click",function(){});
Abdul Quader Mamun 14-Dec-10 6:07am    
Thanks again!!
niravsahayata 15-Dec-10 7:16am    
hey,its not working...
Abdul Quader Mamun 15-Dec-10 7:35am    
I See. Wait.
Abdul Quader Mamun 15-Dec-10 8:49am    
Have you used
<script src="http://code.jquery.com/jquery-1.4.4.js"></script>
And

$(document).ready(function() {
});
C++
$('#btnsave').bind("click",test);
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900