Hidding or deleting text nodes
I need to hide all form's content and replace it ( .find('*').each() {$(this).hide} doesn't work) I have problem hiding text nodes :
<开发者_开发百科;form onsubmit="javascript:... ">
<!--text node --> bad
<input type="radio" name="imgvote" value="1" style="display: none;">
I'm guessing that you're using $("form").children().hide()
which won't hide the text nodes, only elements. Instead you want:
$("form").contents().hide();
But hiding is different to replacing. To completely replace everything inside the form, you can either do:
$("form").html("blah blah <input type='text'>");
Or empty it first, and then append elements:
$("form").empty().append("blah blah <input type='text'>");
Yet another alternative, is to make sure all your text is wrapped nicely in an element (most of the time this is more semantically correct) for example, "bad" should probably be inside a <p>
or a <label>
精彩评论