-1

I need to hide tr by attribute name here is the code

<tr name="see items ordered">
<td>
</td>
</tr>

I tried the below code but its not working

<script type="text/javascript">
var xyz = document.getElementsByName("see items ordered");
xyz[0].style.display="none";
</script>

If is there any way using js,jquery or css to hide by name attribute please assist me.

user2787474
  • 129
  • 2
  • 4
  • 17

4 Answers4

2

Your code seems to be working, you are probably try to access before elements added to DOM, use document.ready to ensure element get added to DOM. Or but the script just before the body ending tag.

Live Demo

$(document).ready(function(){
    var xyz = document.getElementsByName("see items ordered");
    xyz[0].style.display="none";
});

or, putting it just before ending body tag.

<script type="text/javascript">
   var xyz = document.getElementsByName("see items ordered");
   xyz[0].style.display="none";
 </script>
</body>
Adil
  • 146,340
  • 25
  • 209
  • 204
  • Im getting xyz[0] is undefined when im adding this code – user2787474 May 27 '14 at 07:57
  • This is because the getElementsByName did not return the object you are looking for, did you put code in document.ready? or just before ending body tag? as suggested in answer – Adil May 27 '14 at 08:01
  • Did you include jQuery for that? http://stackoverflow.com/questions/1458349/installing-jquery – Adil May 27 '14 at 08:47
  • yes but getting error Blocked loading mixed active content "http://code.jquery.com/jquery-latest.min.js" – user2787474 May 27 '14 at 09:10
  • Can you just put script tag just just before body ending tag as suggested in answer – Adil May 27 '14 at 09:18
  • Its netsuite website my account page – user2787474 May 27 '14 at 09:38
0

You need to wrap the code in dom ready handler. also can use name-value selector to target the tr:

$(document).ready(function(){
  $('tr[name="see items ordered"]').hide();
});
Milind Anantwar
  • 81,290
  • 25
  • 94
  • 125
0

Here is the CSS solution using attribute selector.

this selector will look the see word. Check the DEMO.

tr[name~="see"]
{color:green;}

See the attached screenshot. enter image description here

Kheema Pandey
  • 9,977
  • 4
  • 25
  • 26
0

Maybe this works. Demo here: http://jsfiddle.net/3K8Ft/

<table>
    <tr name="see items ordered">
        <td>
            Test 1
        </td>
    </tr>
    <tr>
        <td>
            Test 2
        </td>
    </tr>
</table>

JS:

var xyz = document.getElementsByName("see items ordered");
xyz[0].style.display="none";
Christian
  • 23
  • 1
  • 12