I simply want to manipulate the elements within the #content div, but $(\'#content\')
doesn\'t seem to work, and yet in other places it does! My relevant code i
There is a difference between a DOM element and a jQuery selection that contains a DOM element. A jQuery selection is a wrapper around the DOM object to make it easier to use. It doesn't have an id
property, but a DOM element does. On the other hand, jQuery does provide a way to access elements' properties using the attr method:
document.getElementById('content').id // access the id property of a DOM element
$('#content').attr('id') // use jQuery to select the element and access the property
The length
property, however, is provided by a jQuery selection, which is why that works fine for you.