jQuery中怎么設(shè)置表單值

今天就跟大家聊聊有關(guān)jQuery中怎么設(shè)置表單值,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。

創(chuàng)新互聯(lián)建站主要業(yè)務(wù)有網(wǎng)站營(yíng)銷策劃、成都做網(wǎng)站、成都網(wǎng)站制作、成都外貿(mào)網(wǎng)站建設(shè)、微信公眾號(hào)開發(fā)、微信小程序開發(fā)、H5建站、程序開發(fā)等業(yè)務(wù)。一次合作終身朋友,是我們奉行的宗旨;我們不僅僅把客戶當(dāng)客戶,還把客戶視為我們的合作伙伴,在開展業(yè)務(wù)的過程中,公司還積累了豐富的行業(yè)經(jīng)驗(yàn)、網(wǎng)絡(luò)營(yíng)銷推廣資源和合作伙伴關(guān)系資源,并逐漸建立起規(guī)范的客戶服務(wù)和保障體系。 

具體內(nèi)容如下

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <script src="js/jquery-1.11.3.min.js"></script>
  <script>
    $(function () {
      $("input[type=button]:eq(0)").click(function () {
        $("#single").val("選擇2號(hào)");
      });
      $("input[type=button]:eq(1)").click(function () {
        $("#multiple").val(["選擇2號(hào)","選擇3號(hào)"]);
      })
      $("input[type=button]:eq(2)").click(function () {
        $(":checkbox").val(["check2","check3"]);//等同于$("input[type=checkbox]").filter(":eq(0),:eq(1)").attr("checked","checked")
        $(":radio").val(["radio3"]);//等同于$("input[type=radio]").attr("checked","checked"),雖然是單選框,取值還是得用數(shù)組
      });
    });
  </script>
</head>
<body>
<input type="button" value="設(shè)置單選下拉框選中"/>
<input type="button" value="設(shè)置多選下拉框選中"/>
<input type="button" value="設(shè)置單選框和多選框選中"/>

<br/><br/>

<select id="single">
  <option>選擇1號(hào)</option>
  <option>選擇2號(hào)</option>
  <option>選擇3號(hào)</option>
</select>

<select id="multiple" multiple="multiple" >
  <option selected="selected">選擇1號(hào)</option>
  <option>選擇2號(hào)</option>
  <option>選擇3號(hào)</option>
  <option>選擇4號(hào)</option>
  <option selected="selected">選擇5號(hào)</option>
</select>

<br/><br/>


<input type="checkbox" value="check1"/> 多選1
<input type="checkbox" value="check2"/> 多選2
<input type="checkbox" value="check3"/> 多選3
<input type="checkbox" value="check4"/> 多選4

<br/>

<input type="radio" value="radio1"/> 單選1
<input type="radio" value="radio2"/> 單選2
<input type="radio" value="radio3"/> 單選3
</body>
</html>

看完上述內(nèi)容,你們對(duì)jQuery中怎么設(shè)置表單值有進(jìn)一步的了解嗎?如果還想了解更多知識(shí)或者相關(guān)內(nèi)容,請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝大家的支持。

網(wǎng)站標(biāo)題:jQuery中怎么設(shè)置表單值
URL標(biāo)題:http://muchs.cn/article2/ijdsoc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)網(wǎng)站建設(shè)網(wǎng)站設(shè)計(jì)公司、網(wǎng)站制作、網(wǎng)站導(dǎo)航營(yíng)銷型網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站網(wǎng)頁(yè)設(shè)計(jì)