Having read the documentation for the remove-function at http://api.jquery.com/remove/, was under the impression that the following code would work.
If I have an input element like this:
<input id="hiddenRatings" name="languageRatings" type="hidden" value="{5, 3, 2, , , {5, 3, 4, , , {5, 3, 2}}}"/>
I thought I would be able to remove it simply by doing
$().ready(function() {
$('#hiddenRatings').remove();
});
But nothing happens, my input element remains. What am I doing wrong?
EDIT: Crap…… It does work! I´m using Chrome tools, and I was looking at the DOM in the Scripts tab rather than the Elements tab. The Scripts tab doesn´t update when the DOM is changed apparently…
My guess is you are meaning to use this:
Using $(document) waits for all the HTML elements to be loaded into the DOM. I’m not sure if $() actually does anything: Your function will be executed before that element is loaded into the DOM (or maybe not even executed at all, since I’m not sure whether “$()” actually works).
Hope that helps