国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > JavaScript > 正文

Jquery實(shí)現(xiàn)點(diǎn)擊按鈕,連續(xù)地向textarea中添加值的實(shí)例代碼

2019-11-20 20:58:16
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

代碼如下:

復(fù)制代碼 代碼如下:

<%@ page language="java" contentType="text/html; charset=gbk"
    pageEncoding="gbk"%>
    <%@ include file="/pages/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript" src="jquery-1.4.js"></script>

<script type="text/javascript">

   $(document).ready(function(){
        $("input[id^='buttonValidate']").click(function(){  //當(dāng)點(diǎn)擊所有的id中包含'buttonValidate'的input標(biāo)簽時(shí),執(zhí)行函數(shù)
         var btnVal=$.trim($(this).val());//trim函數(shù),去掉空格
         var str = $('#textareaValidate').val() + btnVal;//
         $('#textareaValidate').val(str);//
        });
   });
</script>

<title>Insert title here</title>

</head>
<body>
<form  id="form1" name="form1" action="" method="post">
<table  id ="table1" class="base_table" cellspacing="0"  border="1" style="border-collapse: collapse">

 <tr>
  <td >

  <textarea cols="75" rows="5" id="textareaValidate"></textarea>
  </td>
 </tr>
 <tr id="tr1">
  <td>
  <input id="buttonValidate1" type="button" value=" + "/>
  <input id="buttonValidate2" type="button" value=" - "/>
  <input id="buttonValidate3" type="button" value=" * "/>
  <input id="buttonValidate4" type="button" value=" / "/>    
  <input id="buttonValidate5" type="button" value=" ! "/>
  <input id="buttonValidate6" type="button" value=" = "/>
  <input id="buttonValidate7" type="button" value=" < "/>
  <input id="buttonValidate8" type="button" value=" > "/>     
  <input id="buttonValidate9" type="button" value=" & "/>
  <input id="buttonValidate10" type="button" value=" | "/>
  <input id="buttonValidate11" type="button" value=" ( "/>
  <input id="buttonValidate12" type="button" value=" ) "/>
  </td>
 </tr>
</table>
</form>
</body>
</html>


以上實(shí)現(xiàn)的功能:點(diǎn)擊+,則把+添加到textarea中,點(diǎn)擊-,則把-添加到textarea中;

如圖:

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 青铜峡市| 浮山县| 修水县| 郸城县| 云梦县| 凤冈县| 卓资县| 多伦县| 邵阳市| 沈阳市| 饶阳县| 永靖县| 子长县| 乌兰浩特市| 淅川县| 鄂托克旗| 宜阳县| 竹北市| 廊坊市| 德江县| 安岳县| 黎城县| 中牟县| 交城县| 大安市| 磐安县| 晴隆县| 北辰区| 容城县| 苍梧县| 象山县| 进贤县| 中西区| 财经| 泗水县| 措勤县| 巴彦淖尔市| 咸丰县| 民县| 石阡县| 泸州市|