onclick event for dynamic buttons
I have a page where I want to display buttons only when a particular list item is selected. The user can then click on one of five buttons. I am able to put the buttons in a <div> section using this
-
$("li.point").click(function(){
choice = $(this).attr('id');
Competition = $(this).attr('title');
Title = 'Color Prints Regular';
var btns = '<button class="eoy" id="CR" title="Color Prints Regular" type="button">Color Prints R</button>';
btns= btns + '<button class="eoy" id="CA" title="Color Prints Advanced" type="button">Color Prints A</button>';
btns= btns + '<button class="eoy" id="B" title="Black & White" type="button">Black & White</button>';
btns= btns + '<button class="eoy" id="S" title="Slide" type="button">Slide</button>';
btns= btns + '<button class="eoy" id="DR" title="Digital Regular" type="button">Digital R</button>';
btns= btns + '<button class="eoy" id="DA" title="Digital Advanced" type="button">Digital A</button>';
$("h3.comp").text(Competition);
$("div.eoy").show();
$("div.eoy").html(btns);
$("div.mainbottom").click();
});
My problem is the onclick event is not working.
- $("button.eoy").click(function(){
- Comp = $(this).attr('id');
- Title = $(this).attr('title');
- $("div.mainbottom").click();
- });
Any suggestions?
Art