I am using jQuery to replace normal checkbox with image. I am able to replace checkbox with image but unable to set CSS and click handler on image.
This is my jQuery code.
(function ($) {
$.fn.SetOnOff = function (onImage,offImage) {
debugger;
var html = '<img style="width: 80px; height: 30px" src="'+offImage +'"/>';
$(this).replaceWith(html);
$(html).css('cursor','pointer');
$(html).click(function(){
var fileName = $(this).attr('src');
if (fileName == onImage)
$(this).attr('src', offImage);
else
$(this).attr('src', onImage);
});
return $(this);
};
} (jQuery));
can anybody let me know how to do this?
you use This link to test it