Jquery clickable div
Give an div
ID generate
or any other (of course sensible) ID to uniquely select it:
<div id="someid" class="clickme"> click here </div>
<script type="text/javascript">
$(document).ready(function(){
$("#someid").click(function(){
$("#quote p").load("script.php");
});
});
</script>
Please note that the ID must be unique throughout the document.
You can also just use a class to select an element, but it will select any element of that class and bind a handler to all of them:
$(document).ready(function(){
$(".clickme").click(function(){
$("#quote p").load("script.php");
});
});
Read the documentation about selectors , especially ID and class .
source to share
Or specify <div>
a id
of generate
:
<div id="generate">
or replace #generate
with .clickme
in JS:
$('.clickme').click(function() {
// ...
});
This is pretty trivial. To learn more about using jQuery, I highly recommend going through their tutorials . If you prefer a book, I recommend jQuery in action .
source to share