I am working on a jQuery plugin but having some difficulty setting data on an element using jQuery.
I have the code below in an external js file.
var imgtd = $('<td></td>');
var img = $('<img src="' + imgdirectory + '16/arrow_up_green.gif" onclick="' +
'jQuery.multiselectviewer.reOrderMultiSelectViewer(' + index + ', 1, jQuery(this)
.data(\'multiselectEle\'));" alt="Move ' + controlName + ' up in the list">')
.data("multiselectEle", i);
$(imgtd).append(img);
var dat = img.data();
$(row).append(imgtd);
When I set a breakpoint on the last line, I can see the data assigned to the img element but when I check the element after the page has finished loading the call the data() returns null, and when clicking on the image a null value is passed to the called function.
I imagine it is something simple that I am doing wrong but it has got me stuck.