I have the following form
我有以下表格
<form action=“/animals/living” method="POST">
<input name=“cat” placeholder=“cat name”><br/>
<input name=“dog” placeholder=“dog name”><br/>
<input name=“bunny” placeholder=“bunny name”><br/>
Description:<textarea name="description" placeholder="Description" rows="2"
cols="50"></textarea>
Documentation:<br/><textarea name="documentation" rows="8" cols="80"></textarea><br/>
Essay:<br/> <textarea name=“essays” rows="8" cols="80"></textarea><br/>
Passage:<br/> <textarea name=“passage” rows="8" cols="80"></textarea><br/>
<input type="submit" value="Submit">
</form>
Before I submit the form I want to change all the content of the TextArea
s to plainText. I find a jQuery function that supposedly can do it.
在我提交表单之前,我想将TextAreas的所有内容更改为plainText。我找到了一个可以做到的jQuery函数。
var my_plaintext = $(the_richtext).text();
So my question is this:
所以我的问题是:
How do I apply the jQuery function to the textAreas contents and then submit the form?
如何将jQuery函数应用于textAreas内容然后提交表单?
(In case you were still wondering, the content of a TextArea is in RichText format.)
(如果您仍然想知道,TextArea的内容是RichText格式。)
1 个解决方案
#1
0
You can use event.preventDefault()
, .val()
, .submit()
你可以使用event.preventDefault(),. val(),. submit()
$("form").submit(function(e) {
e.preventDefault();
$("textarea", this).val(function(i, value) {
return $("<div/>",{text:value}).text();
});
this.submit();
})
#1
0
You can use event.preventDefault()
, .val()
, .submit()
你可以使用event.preventDefault(),. val(),. submit()
$("form").submit(function(e) {
e.preventDefault();
$("textarea", this).val(function(i, value) {
return $("<div/>",{text:value}).text();
});
this.submit();
})