glenelkins Posted January 20, 2010 Share Posted January 20, 2010 Hi I will explain this the best i can. I am using jQuery in a quite complex application. The part i am stuck on grabs information from a database table with ajax and creates html output. Then assigns the output to an element with innerHTML. The output html contains checkboxes with unique IDs. I wanted these checkboxes to allow a click event, so I created javascript code into a string and also placed this into the document to allow the events be be trapped because when assigning code to an element with Javascript it actually does not really exist. The problem im facing is not the checkbox click even, it picks that up fine, the problem is when I want to use innerHTML after the event is trapped onto one of the generated elements...make sense? So I may have the following code for example (minus ajax): <script type="text/javascript"> // the line below is to trap the checkbox click event and place the date in the <span> // the date does NOT get placed! html = '<script type="text/javascript">$("#test").click ( function() { $("#date").innerHTML ( "14/11/2009" ); } );</script>'; html += '<input type="checkbox" id="test" /> <span class="date" id="date"></span>'; // the next line works fine, shows the checkbox $('#elementname').innerHTML ( html ); </script> Quote Link to comment Share on other sites More sharing options...
glenelkins Posted January 20, 2010 Author Share Posted January 20, 2010 hi the strange thing is, the innerHTML doesnt work in this situation, but if i do comething like .css ('display','none') that works fine Quote Link to comment Share on other sites More sharing options...
glenelkins Posted January 20, 2010 Author Share Posted January 20, 2010 FOUND THE ISSUE! I AM A DUFUS! jQuery doesnt use innerHTML() it uses html() ffs lol Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.