Skip to content

Instantly share code, notes, and snippets.

@christianhager
Created September 22, 2009 12:55
Show Gist options
  • Save christianhager/191043 to your computer and use it in GitHub Desktop.
Save christianhager/191043 to your computer and use it in GitHub Desktop.
<div id="widget"></div>
<script src="http://yourapp.com/widget.js?element=widget"></script>
/*
the code outside the function(container) works nice
what do I do wrong inside?
*/
var newDiv = document.createElement('DIV');
newDiv.innerHTML = "<p>a paragraph outside</p>";
document.getElementById('widget').appendChild(newDiv);
(function(container){
var newDiv = document.createElement('DIV');
newDiv.innerHTML = "<p> a paragraph inside</p>";
$(this).appendChild(newDiv);
/* var list = new Element('ul');
list.insert(new Element('li').update('foo'));
alert('inside does not work');
container.update(list);*/
})($('widget'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment