Dynamically added img and label. how can I click an image to obtain the img and label values?
Function piclist () {var did = $ ('# did '). combobox ('getvalue'); $ ('# dlg '). dialog ('close'); $ ('# dlg_pic '). dialog ('open '). dialog ('settitle', 'ADD'); var pic = 'Pic '; $. ajax ({type: "get", url :".. /php/staff. php ", data:" o = "+ pic, datatype: 'json', success: function (data) {// If php is successfully called, data is the return value after the php file is executed. var obj = eval (data); for (var I = 0; I
"+" "+"
"+ Obj [I]. myname +"
");} Else {$ ('# fm_pic'). append ("
"+" "+"
"+ Obj [I]. myname +"
");}}}});}
I used ajax to obtain data from php and then dynamically added img
Now I want to add an onclick to the image and click the image to pass the obj [I]. pic + label obj [I]. myname values to php.
However, because I added it dynamically, I don't know how to obtain its value.
Function add () {$. messager. confirm ('Add', 'are you sure you want to add? ', Function (r) {$. post ('.. /php/radio. php ', function () {$ (' # dg '). datagrid ('reload ');});});}
Reply to discussion (solution)
Add a unique class that does not repeat at the time of addition.
Unique ID