$("element").click(function(){
/// code here ///
})
We can trigger code by using click event over a button or over some text. Here is the code .
<input type=button value='Click me' id='b1'><div id=t1></div>
JQUERY
<script>
$(document).ready(function() {
$("#b1").click(function(){
$("#t1").html('You clicked the button');
});
})
</script>
<script>
$(document).ready(function() {
$(".edit_class").click(function(){
/// your code for click event here ///
});
})
</script>
Once the event is fired then we can find out which button is clicked by the user.
<script>
$(document).ready(function() {
$(".edit_class").click(function(){
var id = $(this).attr('id');});
})
})
</script>
$("input:radio[name=options]").click(function() {
var value= $(this).val();
})
More on Radio buttons
$('#b1').bind('click dblclick', function(){
// Your code here
});
How to identify which event has triggered ?
$("#b1").on('dblclick click',function(e){
$("#t1").html('Your type of Click event : '+e.type);
});
$('#display_body').on('click', ".edit_class", function () {
// Your code here
})
#display_body is the element to where part of the page is loaded after DOM is created.
Tutorial ( Video ) on textarea counter
| 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