select下拉列表onChange事件之JQuery实现:
- JQuery:
- $(document).ready(function () {
- $("#selectMenu").bind("change", function () {
- if ($(this).val() == "pro1") {
- $("#pro1").slideDown();
- $("#pro2").slideUp();
- }
- else if($(this).val() =="pro2") {
- $("#pro2").slideDown();
- $("#pro1").slideUp();
- }
- });
- });
-
- HTML:
- <select id="selectMenu">
- <option value="" >Please select product below</option>
- <option value="pro1">Product 1</option>
- <option value="pro2">Product 2</option>
- </select>
- $("#select_id").change(function(){
-
- var checkValue=$("#select_id").val();
- var checkValue = $(‘.formc select[@name="country"]‘).val();
- var checkValue=$("#select_id").val().join(",");
-
- var checkText = $("#select_id").find("option:selected").text();
- var checkText = $("select[@name=country] option[@selected]").text();
- var checkText = $("#select_id option:selected").text();
-
- var cc2 = $(‘.formc select[@name="country"]‘).val();
- var cc3 = $(‘.formc select[@name="country"]‘).attr("id");
-
-
- var checkIndex=$("#select_id ").get(0).selectedIndex;
- var maxIndex=$("#select_id option:last").attr("index");
-
- $("#select_id ").get(0).selectedIndex = 1;
- $(‘#select_id‘)[0].selectedIndex = 1;
- $("#select_id ").val(4);
- $("#select_id option[text=‘jQuery‘]").attr("selected", true);
- $("#select_id").attr("value",‘-sel3‘);
-
- $("#select_id").empty();
-
- $("#select_id").append("<option value=‘Value‘>Text</option>");
- $("<option value=‘1‘>1111</option><option value=‘2‘>2222</option>").appendTo("#select_id")
- $("#select_id").prepend("<option value=‘0‘>请选择</option>");
- $("#select_id option:last").remove();
- $("#select_id option[index=‘0‘]").remove();
- $("#select_id option[value=‘3‘]").remove();
- $("#select_id option[text=‘4‘]").remove();
-
-
- var item = $(‘input[@name=items][@checked]‘).val();
- var rval = $("input[@type=radio][@checked]").val();
- $(‘input[@name=items]‘).get(1).checked = true;
- $("input[@type=radio]").attr("checked",‘2‘);
- $("input[@type=radio][@value=2]").attr("checked",‘checked‘);
-
-
- $("#checkbox_id").attr("value");
- $("input[@type=checkbox][@checked]").val();
- $("input[@type=checkbox][@checked]").each(function(){
- alert($(this).val());
- });
- $("#chk1").attr("checked",‘‘);
- $("#chk2").attr("checked",true);
- if($("#chk1").attr(‘checked‘)==undefined)
-
-
- $("#txt").attr("value");
- $("#txt").attr("value",‘‘);
- $("#txt").attr("value",‘11‘);
JQuery操作表单相关使用总结,布布扣,bubuko.com
JQuery操作表单相关使用总结
原文:http://www.cnblogs.com/xiaochao12345/p/3845253.html