views:

41

answers:

2

I have the following code on the page and it works in FF but not IE. I do not have any access to change this line of html code (like adding an id to better target). Could it be that it doesn't work cause there is no DOC type declared?

<td align="LEFT"  width="12%" bgcolor="#EEEEEE"><b>Code</b></td>

<script type="text/javascript" language="javascript">
$(document).ready(function(){
$('td[width="12%"][align="LEFT"] b').hide();
});
</script>
+2  A: 

try changing the case of the text thus:

$('td[width="12%"][align="left"] b').hide();

see in action here: http://jsfiddle.net/mschultheiss/Xjwv7/

Mark Schultheiss
+1  A: 

I was kidding with the above 12 comment, but the issue with IE is indeed the attribute casing, and it is case sensitive, make sure your left is lower-case (if possible render it in the source this way to begin with) then your check should be:

$(function(){
  $('td[width="12%"][align="left"] b').hide();
});

As an aside, consider using CSS classes for things like this:

<td class="code">

Then in your stylesheet:

.code { text-align: left;, width: 12%; }

Then in jQuery you can just use:

$('td.code b').hide();

Much cleaner all around, and a lighter page for the client.

Nick Craver
Believe me I wish I had access to the html to put a class in it but unfortunately I do not.
@user357034 - I kinda figured that was the case, hopefully it'll help someone else finding this later who *does* have the option :)
Nick Craver
and yes I know you were kidding about the 12, lol