[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Button click on jquery

Posted on 2011-10-20
3
Medium Priority
?
430 Views
Last Modified: 2012-05-12
I have a button, onload of the body, need to click the button on jquery function. I found that click() is trigerred on clicking the button manually. is there any way to click the button through jquery function.
0
Comment
Question by:gaurih
3 Comments
 
LVL 83

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 37004420
$("#button1").click(function() { // wait a click from the use
       // to excute the code
})

I think you're looking for : http://api.jquery.com/trigger/

$("#button1").trigger("click");
0
 
LVL 17

Expert Comment

by:sonawanekiran
ID: 37004601
Look at below example how button click event is fired when your change the text in textbox.
Here is demo : http://jsfiddle.net/LRYaq/


<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Kiran Test</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>

<script>
$(document).ready(function(){
 
 $("#txt").keyup(function(){
   $("#btn").click();
 });

 $("#btn").click(function(){
   alert("button is click event fired");
 });
 
 
});
</script>

</head>

<body>

<input type="button" id="btn" value="button click">

<input type="text" id="txt">

</body>
</html>

Open in new window

0
 

Author Closing Comment

by:gaurih
ID: 37004670
Thanks for your quick response.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month17 days, 21 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question