admin管理员组文章数量:1405287
I would like to remove a tag with the class of '.de'.
$('.de').remove();
will remove it from the page but when I check the source code, then I still see the tag.
The problem that I have is, the following tag needs to be removed from the form, otherwise it will get sent and that's not what I want.
<input class="input_field_left de" name="friend_vorname[]" type="text" placeholder="Vorname">
Or maybe there is another way to not let this field get sent?!
I would like to remove a tag with the class of '.de'.
$('.de').remove();
will remove it from the page but when I check the source code, then I still see the tag.
The problem that I have is, the following tag needs to be removed from the form, otherwise it will get sent and that's not what I want.
<input class="input_field_left de" name="friend_vorname[]" type="text" placeholder="Vorname">
Or maybe there is another way to not let this field get sent?!
Share Improve this question asked Jan 5, 2016 at 8:19 Pom CanysPom Canys 3792 gold badges5 silver badges16 bronze badges 2-
2
$('.de').remove();
will remove all the matched elements including those in the form. How can then it be sent to server on form submission? – Tushar Commented Jan 5, 2016 at 8:20 - What exactly are you planning to do? Do you have a form with multiple languages but only want to have the chosen one to be shown? If yes, why don't you create the form dynamically, instead of hardcoding the form and trying to remove the redundant inputs? – Marv Commented Jan 5, 2016 at 8:22
2 Answers
Reset to default 9This is just how "view source" works in browsers. It shows you what came from the server (and usually re-queries it from the server [which may read it from cache]), not what is currently in the page.
To see what's currently in the page, you need to use the "Elements" or "DOM" tab in your browser's dev tools (usually opened via F12 or Ctrl+Shift+I). You can usually open it and move to a specific element by right-clicking that element on your page and choosing "Inspect element", so if you do that with your form after your $('.de').remove();
is run, you'll see the form without the .de
elements in it.
The problem that I have is, the following tag needs to be removed from the form, otherwise it will get sent and that's not what I want.
No, it won't. Your $('.de').remove();
will remove any matching elements from the page, and they will not be submitted with the form if the form is then submitted.
You cannot delete a tag from source code with j Query if you want to do that try to add the tag with jQuery.(Dynamically created tags or elements only can be removed dynamically using jQuery.)
本文标签: javascriptCompletly remove a tag from the sourceStack Overflow
版权声明:本文标题:javascript - Completly remove a tag from the source - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744245608a2596996.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论