jQuery addClass example
Change class name on click in jQuery
by Jason Rose
HTML
<script src="http://code.jquery.com/jquery-1.7.2.js"></script>
<div> 1</div>
<div> 2</div>
<div> 3</div>
<div> 4</div>
JavaScript
$(document).ready(function() {
$.ajax({
type: "GET ",
url: "somefile.xml ",
dataType: "xml ",
sucess: callback
});
});
function callback(data, status) {
var locations = data.getElementsByTagName("location ");
listLocations(locations);
$.each(locations, function() {
$("# " + this).text("the location is " + this + ". ");
}
}