这是我想要获得价值的代码。我没有任何身份证,所以请帮助我。如何使用jQuery和JavaScript获取值?
<p>Nama*<br />
<span class="wpcf7-form-control-wrap your-name">
<input type="text" name="your-name" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-validates-as-required form-control" aria-required="true" aria-invalid="false" />
</span>
</p>
<p>Email*<br />
<span class="wpcf7-form-control-wrap your-email">
<input type="email" name="your-email" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-email wpcf7-validates-as-required wpcf7-validates-as-email form-control" aria-required="true" aria-invalid="false" />
</span>
</p>
<p>Pertanyaan/Cerita*<br />
<span class="wpcf7-form-control-wrap your-message">
<textarea name="your-message" cols="40" rows="10" class="wpcf7-form-control wpcf7-textarea wpcf7-validates-as-required form-control" aria-required="true" aria-invalid="false"></textarea>
</span>
</p>
<p>
<input type="submit" value="Send" class="wpcf7-form-control wpcf7-submit" />
</p>
答案 0 :(得分:4)
使用form
标记应用。并通过serialize()
函数获取。它显示输入字段的所有值
$(document).on('click' ,'input[type=submit]' ,function () {
console.log($('form').serialize());
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form><!---its help full to get all value.--->
<p>Nama*<br />
<span class="wpcf7-form-control-wrap your-name">
<input type="text" name="your-name" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-validates-as-required form-control" aria-required="true" aria-invalid="false" /></span> </p>
<p>Email*<br />
<span class="wpcf7-form-control-wrap your-email">
<input type="email" name="your-email" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-email wpcf7-validates-as-required wpcf7-validates-as-email form-control" aria-required="true" aria-invalid="false" /></span> </p>
<p>Pertanyaan/Cerita*<br />
<span class="wpcf7-form-control-wrap your-message">
<textarea name="your-message" cols="40" rows="10" class="wpcf7-form-control wpcf7-textarea wpcf7-validates-as-required form-control" aria-required="true" aria-invalid="false"></textarea></span> </p>
<p><input type="submit" value="Send" class="wpcf7-form-control wpcf7-submit" /></p>
</form>
答案 1 :(得分:1)
您可以通过其use an attribute equals selector的名称属性获取元素。
library(dplyr)
library(tidyr)
gather(tmp_dat, Var, Val, Score1:Score3) %>%
mutate(TimeN = 'Time', Var = sub("\\D+", "", Var)) %>%
unite(Time1, TimeN, Time, Var) %>%
spread(Time1, Val)
# # A tibble: 3 × 7
# Person Time_Post_1 Time_Post_2 Time_Post_3 Time_Pre_1 Time_Pre_2 Time_Pre_3
# * <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#1 greg 79 80 84.5 80 78 84.0
#2 sally 78 78 83.0 75 74 79.5
#3 sue 82 NA NA 81 78 84.5
答案 2 :(得分:0)
在jQuery中,您可以按var name = $('[name="your-name"]').val(),
email = $('[name="your-email"]').val();
选择字段。
name
答案 3 :(得分:0)
jQuery的:
var name = $(".your-name").val();
var email = $(".your-email").val();
var message = $(".your-message").val();