I have multiple buttons that gets created in a table which all look like this:
<button class="editbutton">Edit</button>
In this table the button will have a type associated with it, either APPLE or ORANGE.
What I want to do is pass in this type into my javascript to open up a jquery dialog. I could do something like this:
<button class="editbutton" onclick="edit('<?php echo $result[$i]["type"]; ?>');" >Edit</button>
Then do the processing in the edit function now that I have the type. But the way my code is structured I’m looking for a way to pass in the type without creating a function (just because the way I’ve structured the code). So I need to know when the button clicked if it is the APPLE or ORANGE so I can open up a specific jquery dialog.
Hopefully it is clear what I’m looking for.
Attach a click listener to your button – http://jsfiddle.net/XPQ5Y/