0

My HTML format looks like this :

<body>
   <table>
      <tbody>
         <tr>
           <td></td>
           <td><span><input type="button"/></span></td>
         </tr>
      </tbody>
  </table>

    <table>
      <tbody>
         <tr>
           <td></td>
           <td><span><input type="button"/></span></td>
         </tr>
      </tbody>
  </table>
</body>

I want to hide all buttons without using class and ID. I've tried everything to hide the buttons but its not working.

What I've tried is something like this :

document.getElementsByTagName('input').style.visibility = "hidden";

and

input_list = document.getElementsByTagName('input');
for (element in input_list) {
 element.style.visibility = "hidden";
}
secretgenes
  • 1,291
  • 1
  • 19
  • 39

5 Answers5

2

if you want to hide all buttons in your form use

       $("input[type^=button]").each(function (index) {
         $(this).hide();
        });

UPDATE: may be this could help you

        var ele = document.getElementsByTagName("input");
        if (ele.length > 0) {
            for (i = 0; i < ele.length; i++) {
                if (ele[i].type == "button")
                    ele[i].style.display = "none";
            }
        }
Learner
  • 59
  • 1
  • 7
1

I hope this will make u sense with javascript

var i =document.getElementsByTagName("input");

for( var n in i){
    if(i[n].type = "button"){ 
      alert("hide button "+n);    
      i[n].style.visibility = "hidden";    
      }
}
<body>
   <table>
      <tbody>
         <tr>
           <td></td>
           <td><span><input type="button"/></span></td>
         </tr>
      </tbody>
  </table>

    <table>
      <tbody>
         <tr>
           <td></td>
           <td><span><input type="button"/></span></td>
         </tr>
      </tbody>
  </table>
</body>
Jack jdeoel
  • 4,554
  • 5
  • 26
  • 52
0

You can use jquery to hide all buttons

Just use

$('input').hide();

Check this fiddle -> https://fiddle.jshell.net/c8tqvy0r/

Anoop B.K
  • 1,484
  • 2
  • 17
  • 31
0

You can write in jquery

jQuery('input[type="button"]').hide();

or through css you can give

input[type="button"]{
  display:none;
}

or

input[type="button"]{
  opacity:0;
}
0

Instead of using

for (element in input_list) 

use

for(var i=0; i < input_list.length; i++){

    input_list[i].style.visibility = "hidden";

}
krishna
  • 154
  • 7