Js中常用方法

  1. 获取input标签的val值

id: $('#id').val();
name: $('input[name = "name"]').val();

  1. 获取input标签选中的val

$('input[name = "name"]: checked').val();
$('input[name = "name"]: selected').val();

  1. 获取select标签选中的val

id :$('#id').val() 获取选中的option 的value
$('#id').text() 获取选中的option 的文本
$("#id").find("option:selected").text();

  1. 将input标签隐藏<input type="hidden">

  2. 判断当前的标签时显示还是隐藏

$('#id').is(':visible')

  1. 将当前的标签时显示还是隐藏

$('#id').show()
$('#id').hide()

  1. 将标签选中和不选中

$('#id').attr('checked',true);
$('#id').attr('checked',false);

posted on 2018-11-02 16:49  觉绝  阅读(214)  评论(0编辑  收藏  举报

导航