remove element : doesn't work.
I try to remove element using JQuery, but it doesn't work. The javascript DOM version will work.
JQuery doesn't support bracket and dot in id value ?
Thanks.
- // doesn't work
function removeCar(idx){
alert($('#carListDiv').html()); // see the innerHTML
$('#carListDiv').remove('#car[0].headdiv');
}
// works
function removeElement(idx) {
var olddiv = document.getElementById('car[0].headdiv');
olddiv.parentNode.removeChild(olddiv);
}
The html is
<div id='carListDiv'>
<div id="car[0].headdiv" class="msg_head"><a style="float:right;" href="#" onclick="removeCar(0);">remove</a> New Car - not saved </div>
<div id="car[0].msgdiv" class="msg_body" >
<p><label for="car[0].carId" >Car ID :</label> <input type="text" id="car[0].carId" name="car[0].carId" value="" /></p>
<p><label for="car[0].madeyear">madeyear :</label><input type="text" id="car[0].madeyear" name="car[0].madeyear" value="" /></p>
</div>
</div>