Dynamically added img and label. how can I click an image to obtain the img and label values?

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.