I am using jQuery on button click to show div but don’t know why its not working…
HTML:
<input type="button" id="addmoresg" value="Add More" name="button">
<div id="addsg" style="display:none">
<!-- more HTML here -->
</div>
JavaScript:
$(document).ready(function() {
$('.addmoresg').click(function() {
$('.addsg').show("slow");
});
});
jsFiddle demo: http://jsfiddle.net/XGVp3/
I am not getting any result on button click.
2 problems:
You use
classselectors [docs] (.addmoresg) instead ofidselectors [docs] (#addmoresg). Your elements only haveids, notclasses:$('.addmoresg)would select elements withclass="addmoresg", e.g.Working demo
jQuery has a great documentation and a list of all possible selectors, with examples.