zoukankan      html  css  js  c++  java
  • JQUERY取值

    文本框操作
    取    值:var textval 
    = $("#text_id").attr("value");
                var textval 
    = $("#text_id").val();
    清除内容:$(”#txt”).attr(”value”,”);
    填充内容:$(”#txt”).attr(”value”,’
    123′);

    文本域操作
    取    值:var textval 
    = $("#text_id").attr("value");
                var textval 
    = $("#text_id").val();
    清除内容:$(”#txt”).attr(”value”,”);
    填充内容:$(”#txt”).attr(”value”,’
    123′);

    单选按钮操作
    取    值:var valradio 
    = $("input[@type=radio][@checked]").val(); //只有一组Radio情况下
                var valradio =$('input[@name=chart][@checked]').val(); //多组Radio情况下,根据name取一组的值

    下拉框操作
    取    值:var selectval 
    = $('#sell').val();
    设置选中:$(
    "#select_id").attr("value",'test');//设置value=test的项目为当前选中项
    添加新项:$("<option value='test'>test</option><option value='test2'>test2</option>").appendTo("#select_id")//添加下拉框的option
    清空下拉框:$("#select_id").empty();//清空下拉框

    多选框操作
    取    值:$(
    "#chk_id").attr("checked",'');//未选中的值
                $("#chk_id").attr("checked",true);//选中的值
                if($("#chk_id").attr('checked')==undefined) //判断是否已经选中
  • 相关阅读:
    apache-kylin 权威指南—读书笔记
    数据仓库之数据仓库环境——读书笔记
    R 语言—基本绘图
    MapReduce 过程分析
    HDFS 的运行机制
    R 语言贷款月供数据分析
    UML 简介笔记
    为什么要学习 UML?
    scrum 项目的基本模式
    elasticsearch 集群配置
  • 原文地址:https://www.cnblogs.com/ringwang/p/2051896.html
Copyright © 2011-2022 走看看