Friday, May 24, 2024
 Popular · Latest · Hot · Upcoming
73
rated 0 times [  78] [ 5]  / answers: 1 / hits: 24453  / 13 Years ago, sat, august 13, 2011, 12:00:00

Ok, correct me if I'm wrong, but I take it that jQuery attr() does NOT work in IE. (marked wontfix) That being the case, what is the best alternative? For example, this works everywhere but IE:



jQuery(document).ready(function($) {
$('.airsrc').each(function() {
var $this = $(this);
var src = $this.attr('data-websrc');
$this.attr('src', src);
});
});


Update: Whoops...I realize the issue. I actually had this inside an if statement based on a CSS3 media query. Media queries that aren't natively supported in IE8 or lower. The attr() definitely works!


More From » jquery

 Answers
16

I use attr with data-* attributes on IE all the time, I've never had a problem. Here's a live version, just tested in IE6, IE7, and IE9. Don't have my IE8 box handy, but again, I've never had a problem.


[#90629] Friday, August 12, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
brooksb

Total Points: 480
Total Questions: 98
Total Answers: 106

Location: Somalia
Member since Mon, Feb 27, 2023
1 Year ago
brooksb questions
Tue, Nov 9, 21, 00:00, 3 Years ago
Mon, May 4, 20, 00:00, 4 Years ago
Wed, Mar 11, 20, 00:00, 4 Years ago
;