Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- multiple use of 'html()' in jQuery


sssweb - 4:36 pm on May 1, 2012 (gmt 0)


I'm using jquery to change the html content of a div when certain buttons are clicked. The code works fine on the first change. But if I then click a different button to change it to something else, I get a blank div (no text). I know all buttons work because when I try each of them first, they change the content correctly.

Do I have to re-set something after each change to get the next one to work?

Here's sample code I'm using:

$( "#button1" ).click(function() {
var htmlStr = $( "#text2" ).html();
$("#change-div").html(htmlStr);
});


Thread source:: http://www.webmasterworld.com/javascript/4448054.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com