Click here to Skip to main content
15,908,634 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
the code is given below:
HTML
<div id="1">
<input type="hidden" name="name" value="dgfdf" class="chk"/>
<input type="hidden" name="email" value="gh@yahoo.com" class="chk"/>
<input type="hidden" name="phone" value="475684" class="chk"/>
<input type="hidden" name="address" value="f46d/a" class="chk"/>
<input type="hidden" name="id" value="2" class="id"/>
</div>



here i want to change 'type hidden to text' all input fild which class name is
chk
inside div id 1.how can i do this using javascript.
For more understand i give the changed code below:

HTML
<div id="1">
<input type="text" name="name" value="dgfdf" class="chk"/>
<input type="text" name="email" value="gh@yahoo.com" class="chk"/>
<input type="text" name="phone" value="475684" class="chk"/>
<input type="text" name="address" value="f46d/a" class="chk"/>
<input type="hidden" name="id" value="2" class="id"/>
</div>


What I have tried:

i cannot understand how should i start.
Posted
Updated 25-Oct-16 7:56am

Hello
If you are designing a site that is intended only to run on Mozilla, Safari, or another non-Internet Explorer browser, the following code is sufficient to modify an input element's type:

JavaScript
<script>
  document.getElementsByClassName('chk').type = 'text';
</script>


hope it works
 
Share this answer
 
Comments
Member 9361273 26-Oct-16 2:00am    
Hello.
First of all thanks for the solution.
I know it but here i want to know how can I change all input type inside div 1.
Ali Majed HA 26-Oct-16 2:17am    
Hello
You can use :
$('#1').find('.chk').type = 'text';
it will return the classes inside div 1
hope it works
W Balboos, GHB 27-Oct-16 7:01am    
Note that the question specifies javaScript - not JQuery !
try this
JavaScript
var div = document.getElementById('1'); 
            var chks = div.getElementsByClassName('chk'); 
            for (var i = 0; i < chks.length; i++) { 
                chks[i].type = 'text';
            }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900