在jQuery中使用选择器 [英] using selectors in jquery

查看:58
本文介绍了在jQuery中使用选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是jquery的新手.
我有不同的控件,例如具有相同的div标签文本框,复选框,组合框等,我已经在这些控件中输入了值.使用jQuery,我想从这些控件中检索所有值,我想将其存储到一个对象.

怎么做.我没有得到
请帮帮我.

谢谢.

I am new to jquery.
i have different controls like with same div tag textbox, checkbox, combobox etc., i have entered the values in these controls. using jquery i want to retrieve all the values from these controls and i want to store it to one object.

how to do. i am not getting
please help me .

thank you.

推荐答案


如果您不熟悉Jquery,请关注此站点.这很有帮助
http://www.w3schools.com/jquery/default.asp [
Hi,
If you are new to Jquery, then follow this site. It is very much helpful
http://www.w3schools.com/jquery/default.asp[^]


请考虑您是否拥有以下控件您的页面:
consider you have these controls on your page:
<div id="myDiv">
       my div text
   </div>
   <input type="text" id="txt1" />
   <select id="ddl1">
       <option value="1">Test</option>
       <option value="2">Test 2</option>
   </select>
   <input type="checkbox" id="chk1" /><label for="chk1">Check Box</label>

   <input type="button" id="btn1" value="Get Value" onclick="GetValues();"/>


现在,在按钮上单击,调用此javascript函数以获取所有控件值,如下所示:


now on the button click call this javascript function to get all controls values like this:

<script type="text/javascript">
      function GetValues() {
          alert("my DIV content is " +


(' #myDiv').html()); alert(" +
('#myDiv').html()); alert("my text box value is " +


这篇关于在jQuery中使用选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆