RadhaKrishnaKiJaya
asked on
Make Java script click event dynamic
Hi Experts,
I have this Java script. How can I make the click dynamic so that this function can be called on the click event of any button.
Thanks.
<script type="text/javascript">
$(document).ready(function () {
$('#btnSubmit').click(func tion () {
$('.blockMe').block({
message: 'Please wait...<br /><img src="Image/Wait.gif" />',
css: { padding: '10px' }
});
});
});
</script>
I have this Java script. How can I make the click dynamic so that this function can be called on the click event of any button.
Thanks.
<script type="text/javascript">
$(document).ready(function
$('#btnSubmit').click(func
$('.blockMe').block({
message: 'Please wait...<br /><img src="Image/Wait.gif" />',
css: { padding: '10px' }
});
});
});
</script>
Use jQuery button selector $( ":button" ) or $( "button, input[type='button']" ) like below
<script type="text/javascript">
$(document).ready(function () {
$(':button').click(function () {
$('.blockMe').block({
message: 'Please wait...<br /><img src="Image/Wait.gif" />',
css: { padding: '10px' }
});
});
});
</script>
ASKER
Hi Prakash,
Thank you for your reply. How can I pass the ID of the button to this function. For example if submit button is click then it should btnSubmit and if btnSave is clicked then btnSave.
Thanks.
Thank you for your reply. How can I pass the ID of the button to this function. For example if submit button is click then it should btnSubmit and if btnSave is clicked then btnSave.
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you.
$('A').click(function () {
Hope that is what you are looking for