jQuery - Firefox working, IE not

Not sure if this is a jQuery or an ASP.NET question. On http://www.franciscosautorepair.com/huntington-beach-ford-brakes.aspx (and similar pages) I’ve inserted a coupon image after the first H2 on each page and it is showing up in FF but not in IE. I am wondering if somehow the .NET code is messing up the jQuery code in IE. I’m more of a PHP programmer but I started working on this site after somebody had already built it in .NET.

Changing it to JPG didn’t help anything. It looks like IE doesn’t like the code in the Google-hosted jQuery file. Still investigating…

Okay, problem solved when I changed

:first-of-type

to

:first

in the jQuery code. Guess I’m getting my CSS/jQuery pseudo-selectors mixed up.

insertAfter
You’re the one doing it the wrong way around :slight_smile:

The problem is that your code looks to be the wrong way around.

Try this:


$('H2:first-of-type').insertAfter('<div style="margin-left: 11px; float: right;">
<img src="images/automotive-repair-huntington-beach-coupon-franciscos-auto-repair.png" alt="" />
</div>');

.NET code very rarely causes issues with browser compatibility. Unless your outputting client side code from .net. It is giving jquery error in my IE8. So check that out. The jQuery posted above does not look right to me. You should be targeting images with attributes such as a class or ID.

I took a look at the view-source using Firefox

<h2>Ford Radiator Repair Huntington Beach</h2>
<br />

There was nothing inserted after the h tag.

Ill move the thread over to javascript.

I suspect it may be the image itself. I see this javascript code

$('<div style="margin-left: 11px; float: right;">
<img src="images/automotive-repair-huntington-beach-coupon-franciscos-auto-repair.png" alt="" />
</div>').insertAfter("H2:first-of-type");

If you temporarily try inserting a jpg file instead of a png does it work?