I am developing a mobile website. I have created dynamic buttons in java-script. Now I want to bind two events with each button.
1) when pressed, change background image of the button to img-pressed.jpg. Note: Every button has its own normal and pressed image source.
2) when clicked, do something.
I am very much confused to work with these two events together.
ItemsToAdd += '" id="'+ appVal.id +'">\
<a id="' + appVal.id + '" data-role="button" style="background-image:url('+ img_path + appVal.big_icon_normal_path +')" class="custom-button" href="#"></a>\
<p><br><b>' + appVal.name + ' </b><br> ' + appVal.apptypename + '<br><i>' + appVal.price + '</i></p> </div>';
$("#appGrid" + catVal.id).append($(ItemsToAdd));
$("#appGrid" + catVal.id).trigger("create");
$("#appGrid" + catVal.id + " > #" + appVal.id + " > #" + appVal.id ).bind('click', function ()
{
updateAppInfo(appVal.id);
});
The code is working fine on the click event. Actually i am changing some content on the button click. Now i want to change the source of the image when pressed and change to source to normal when press is released. Content change should also work with it.
I will appreciate you help. Thanks in advance.