JQuery给textarea取值和赋值
取值
var qrcodefortemcontent=$("#qrcodefortemcontent").val();
赋值
$("#qrcodefortemcontent").val(“123”);
-有网友反馈 textarea 没有 val()方法,下面我给出例子,需要引入 jquery.js
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="https://ss1.bdstatic.com/5eN1bjq8AAUYm2zgoY3K/r/www/cache/static/protocol/https/jquery/jquery-1.10.2.min_65682a2.js"></script>
</head>
<body>
<script type="text/javascript">
$(function(){
alert("hello");
alert($("#demoid").val());
$("#demoid").val(7890);
alert($("#demoid").val());
});
</script>
123
<textarea rows="10" cols="10" id="demoid">
1234
</textarea>
</body>
</html>
JQuery给label
取值
next_openid=$("#next_openid2").text();
$("#hasnext2").text('YES');
$("#hasnext2").text('YES');
JQuery给input
取值
qrcodeforeverflag=$("#qrcodeforeverflag").val();
赋值
$("#qrcodeforeverflag").val(“123”);
在html标签中使用‘’或者“”有时候是有差异的,使用“”保险些,但是在存在转义的时候需要用''