-1

I have an ajax script to load json data from server.. and I create a radio button from this data using js.. after that I want to manipulate it with jQuery but I can't.. can you explain me?

This the ajax js..

function cs_mediaJson(link,selector)
{
$.getJSON(link,function(data){
        $.each(data,function(i,item){
            var openTag = "<div class='col-lg-2'>";
            var closeTag = "</div>";

            openTag += "<input class='media-radio' id='media-radio' type='radio' name='media-radio[]' value='"+item.id+"'>";
            openTag += "<label class='label'><img width='100%' height='100%' src='"+item.post_content+"100x100-"+item.post_title+"'></label>";
            openTag += closeTag;

            $(selector).append(openTag);
        });
});
}

The function of that code is to make radio button from json.. and I want to manipulate the radio button like, if I click it I will get the value and display the value to an input textbox ... please help me guys as I am new to JS

devnull69
  • 16,402
  • 8
  • 50
  • 61
cold coffe
  • 13
  • 1
  • 5

2 Answers2

0

After appending data, you should run these manipulating functions one more time

Paul Bönisch
  • 294
  • 2
  • 10
0

You can use on.(event, function(){...})to manipulate an element that was added to the DOM afterwards.

Marcel
  • 674
  • 4
  • 15