jquery 폼 요소 가져오는 방법

8293 단어 jquery
/*  TEXT.AREATEXT  */
var textval = $("#text_id").attr("value");
//  
var textval = $("#text_id").val();
 
/*        */
var valradio = $("input[type=radio]:checked").val();
 
/*      (items) radio      */
var item = $('input[name=items]:checked').val();
 
/*       */
var checkboxval = $("#checkbox_id").attr("value");
 
/*        */
var selectval = $('#select_id').val();
 
/*   ,    */
$("#text_id").attr("value",");//    
$("#text_id").attr("value",'test');//    
 
/*   checkbox*/
$("#chk_id").attr("checked",");//     
$("#chk_id").attr("checked",true);//  
if($("#chk_id").attr('checked')==true) //        
 
/*   radio*/
$("input[type=radio]").attr("checked",'2');//  value=2         
 
/*   select*/
$("#select_id").attr("value",'test');//  value=test         
$("testtest2").appendTo("#select_id")//      option
$("#select_id").empty();//     
 
/*      (items) radio      */
var item = $('input[name=items]:checked').val(); //       val() = undefined
 
/*  select       */
var item = $("select[name=items] option:selected").text();
 
/*select               */
$('#select_id')[0].selectedIndex = 1;
 
/*radio               */
$('input[name=items]').get(1).checked = true;
 
/*    */
$("form").each(function(){
.reset();
});
JS         
    function show()
{
var tab = document.getElementById("test") ;
      //    
      var rows = tab.rows.length ;
      //    
      var cells = tab.rows.item(0).cells.length ;
alert("  "+rows+"  "+cells);
}
  Jquery  Table td    
$(this).children().eq(1).text()        
$(this).children().eq(1).html()    <td></td>       
$('.trSelected',grid).find("td").eq(7).text();            

 

   <table id="gird".....

$("#grid tr").each(function() {
             alert($(this).children().eq(1).text());
 });

 

 javascript   

function load(){
     var tab=document.getElementById("grid");
     var rows=tab.rows;
     alert(rows.length);
     for(var i=0;i<rows.length;i++)
     {
        for(var j=0;j<rows[i].cells.length;j++)
        {
       alert(" "+(i+1)+" , "+(j+1)+"    :"+rows[i].cells[j].innerHTML);
        }
     }
   }
JS           
<html>
<head>
<title>getTableContent</title>
<script language="javascript">
        function getTableContent(rowIndex) {
                var node = document.getElementsByTagName("table")[0];//       
                var child = node.getElementsByTagName("tr")[rowIndex - 1];//          
                var text = child.firstChild.innerHTML;
                window.alert("   " + rowIndex + "    : " + text);
        }
</script>
</head>
<body>
<table width="200" border="1" cellpadding="4" cellspacing="0">
        <tr>
                <td height="25">   </td>
        </tr>
        <tr>
                <td height="25">   </td>
        </tr>
        <tr>
                <td height="25">   </td>
        </tr>
        <tr>
                <td height="25">   </td>
        </tr>
</table>
<br>
<input type="text" name="rowIndex" value="           ?" size="22"> <input type="button" name="getTableContent" value="      " onclick="getTableContent(rowIndex.value)">
</body>
</html>
#Javascript



js    、  table      
<table border=1 width=200 height=150 id='tab'>
<tr><td>111</td><td>111</td></tr>
<tr><td>222</td><td>222</td></tr>
<tr><td>333</td><td>333</td></tr>
<tr><td>444</td><td>444</td></tr>
</table>
<p align=center><input type='button' onclick='change()'>
<script>
function change(){
document.getElementById('tab').rows[0].childNodes[0].innerText = 'aaa';
}
</script>

--------------------------------------------------------------------------------

<table id="test">
<tr>
<td>hello</td>
</tr>
</table>
<script language="JavaScript">
alert(document.getElementById("test").rows[0].cells[0].innerText); 
</script>

 

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>     </title>

</head>

<body>
<table id="tb">
<tr>
<td>title</td>
<td>title1</td>
</tr>
<tr>
<td>test</td>
<td>test1</td>
</tr>
</table>
<input type="button" onClick="show(tb,result);" value="  ">
<input type="text" size=10 name="result">
<script language="javascript">
function show(tb,txt)
{
document.all.result.value=document.all.tb.rows(1).cells(1).innerHTML;
}
</script>
<table width="800" border="0" cellspacing="0" cellpadding="0">
<tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
</tr>
<tr>
    <td>&nbsp;</td>
    <td><span id="feedback_info" style="color:#FF0000"></span></td>
    <td>&nbsp;</td>
</tr>
<tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
</tr>
<tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
</tr>
<tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
</tr>
</table>
<script>

document.getElementById("feedback_info").innerHTML="aaaaaa";

document.all.tb.rows(0).cells(1).innerHTML="aaaaaa";
</script>
</body>
</html>

 

 

js  <table>      


 

1.                

var tid=listFrame.now.rows[1].cells[2].innerHTML;

listFrame        frame
now     id 
rows[i]           :length
cells[j]          rows[i].cells[j]   i  j 
innerHTML       

2       

function reurl(){
url = location.href; //             url
var times = url.split("?"); //     url       "?"
if(times[1] != 1){ //  ?      1      
url += "?1"; //    url      ?1
parent.parent.location.reload() //    

}
else{
reutrn false;
}
}

 

좋은 웹페이지 즐겨찾기