I have an input button that has an onclick attribute function attached to it. I want in the javascript function that is called to change the class of the button that was pressed. The problem is there are multiple buttons on the page so I’m not sure what I would need to write in the javascript function to select the button that was pressed. Here is the code below.
<script type="text/javascript" >
function load(thefile, div) {
$.get(thefile, function(data){
$('#' + div).html(data);
});
};
</script>
<input type="button" class="highlighted" value="upvote"
onclick="load('ajax_file','div')" />
Pass
thisas param and you will get the button pressed:A simple jsfiddle test here.