I am trying to wrote a script that, when the page is loaded, change the content inside 2 divs. At the moment the script should only put the variable inside the div but my next step will be to write the same script using arrays.
At the moment the script is not working and I can”t figure out why…have I to use AJAX instead of .html()?
The page:
<div class="think_infobox">
<h4 class="infbox" id="infbox_title">
original title
</h4>
<p class="infbox" id="infbox_body">
original body
</p>
The script
$(document).ready(function(){
var title = 'my new title';
var body = 'my new body';
$(#infbox_title).html(title);
$(#infbox_body).html(body);
});
The same code on jsFiddle
http://jsfiddle.net/G8F9a/
You forgot the
"chars before and after the id (single quotes is good too). It should be like this: