开发者

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&nbsp;
      <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>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜