Js uses the loop to clear the input tag value in a div, divinput
HTML page
<Div class = "col-xs-9" id = "search_songs_a"> <table> <tbody> <tr> <th> piano Name: </th> <td> <input type = "text" name = "info [gqq_name]" id = "gqq_name" style = "width: 200px; "/> </td> <th style =" padding-left: 10px; "> performer: </th> <td> <input type = "text" name = "info [gqq_player]" id = "gqq_player" style = "width: 200px; "/> </td> </tr> </tbody> </table> lt; /div> <div class = "col-xs-9" id = "search_songs_ B"> <table> <tbody> <tr> <th> property: </th> <td> <span> <input type = "radio" name = "info [gqq_shuxing]" value = "unlimited" checked = "checked"/> <label> unlimited </label> </span> <input type = "radio" name = "info [gqq_shuxing]" value = "Popular Piano Music"/> <label> popular piano music </label> </span> <input type = "radio" name = "info [gqq_shuxing]" value = "classical piano music"/> <label> classical piano music </label> </span> <input type = "radio" name = "info [gqq_shuxing]" value = "Jazz Piano"/> <label> jazz piano </ label> </span> <input type = "radio" name = "info [gqq_shuxing]" value = "Piano exercise"/> <label> piano exercise </label> </span> </td> </tr> </tbody> </table> lt; /div>
Js page
// Clear the Piano Music Search Condition function clearsongs () {$ ("# search_songs_a: input "). each (function () {$ (this ). val ("") ;}); $ ("input [name = 'info [gqq_shuxing] '] [value = 'unlimited']"). attr ("checked", true );}
Use js to obtain the number of all texts under a div
Var aa = document. getElementById ("divName"). getElementsByTagName ("input ");
Var num = 0;
For (var I = 0; I <aa. length; I ++ ){
If (aa. type = "text "){
Num ++;
}
}
Alert (num)
Question about passing DIV values to INPUT using JS
<Input type = "text" value = "I am the value of abcdiv" id = "abcdiv"/>
<Input type = "text" value = "" id = "abc"/>
<Input type = "button" value = "past" onclick = "OK ()"/>
JS:
Function OK (){
Document. getElementById ('abc'). value = document. getElementById ('abcdi'). value;
}