Tag Archives: javascript

Updating div content using JQuery and AJAX

I just noticed something weird when using JQuery ajax ($.get and $.post) to update the content of a div. I use the html function of JQuery to put the content inside the div like this :


Everything worked fine with following div :

<div id="someId"></div>

But, as I work with xml a lot, I am used to writing empty tags as such :

<div id="someId"/>

Suddenly, the div would not get the content from the html function anymore! My only possible explanation is that the <div id="someId"></div> implicitly contains an empty text node (which will be replaced with the html), while the <div id="someId"/> does not have any content at all.

Showing or hiding certain elements depending on option list

A few times already I found myself doing al sorts of special stuff to show or hide certain html elements (mostly input fields) depending on the selected value of a dropdown. After searching the web a bit, I found the following link which makes this really easy and manageable :


It uses JQuery but it should be usable using other libraries as well… Have fun hiding !