本文實(shí)例講述了jQuery根據(jù)表單name獲取值的方法。分享給大家供大家參考,具體如下:
根據(jù)name取值:
$("input[name='mobile']").val()
根據(jù)id取值:
$("#mobile_reg_form").html()
根據(jù)name取值遍歷:
$("input[name='mobile']").each( function(){ alert($(this).val()); } )
取出form中的input:
<script type="text/javascript" language="JavaScript" charset="UTF-8"> $(document).ready(function(){ var a=$("form input"); $.each( a, function(name,object){ alert(name+":"+$(object).val()); } ); }); </script>
得到值(多個(gè)的情況):
$("input[name='mobile']")[0].value $("input[name='mobile']").get(1).value
jquery添加刪除樣式
給一個(gè)標(biāo)簽添加樣式:
$("#id").addClass("style");
刪除一個(gè)標(biāo)簽的樣式:
$("#id").removeClass("style");
注:"#id" id是對(duì)應(yīng)標(biāo)簽的id,style是對(duì)應(yīng)css樣式的名稱
更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jquery中Ajax用法總結(jié)》、《jQuery表格(table)操作技巧匯總》、《jQuery拖拽特效與技巧總結(jié)》、《jQuery擴(kuò)展技巧總結(jié)》、《jQuery常見經(jīng)典特效匯總》、《jQuery動(dòng)畫與特效用法總結(jié)》、《jquery選擇器用法總結(jié)》及《jQuery常用插件及用法總結(jié)》
希望本文所述對(duì)大家jQuery程序設(shè)計(jì)有所幫助。