Home › Forums › JavaScript › my basic jquery not working › Re: my basic jquery not working
December 20, 2012 at 6:54 am
#118239
SgtLegend
Member
Just a couple of nitpicks, the below is the recommended way of writing jQuery.
// This is the shorthand way of writing $(document).ready()
$(function() {
// Since jQuery 1.5 its now recommend you use the on() method
$(‘p’).on(‘click’, function() {
// Always use “this” as it referrers to the current element context not every p element
$(this).hide();
});
});