0

I am currently using this function to add to the style attribute of posternew imgframe div's:

$(function () { $('.posternew .imgframe').each(function () { 
    $(this).attr("style", $(this).attr("style").replace("background:", ""));
    $(this).attr('style', 'background:url(images/new.png),' + $(this).attr('style')); 
    });  
});

This works perfectly in Chrome and Firefox, but will not under IE 9 or 10. I've tried formatting it slightly differently, but to no avail. Any ideas as to why this will not work in IE?

This creates this html in Chrome and Firefox:

<div class="imgframe" style="background:url(images/new.png), url(images/boxart/blah.jpg);"></div>

But in IE shows:

<div class="imgframe"/>
1
  • 2
    Have you heard anything about .css() method? Commented Jan 6, 2013 at 17:49

1 Answer 1

3

How about that?

$(".posternew .imgframe").css("background-image", "url('images/new.png')");

No need in parsing style attribute, just use .css().

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.