Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
-1
rated 0 times [  0] [ 1]  / answers: 1 / hits: 18633  / 10 Years ago, wed, june 25, 2014, 12:00:00

Im using a flexslider that has audio files for each slide, but I don't want to load countless audio files right away on the page. So im trying to get the data-src to become the src after each slide



the slides are currently as follows:



<div class=flexslider carousel>
<ul class=slides>
<li>
<img src=http://www.quinnmedical.com/skin/frontend/gigasavvy/quinn/ppt/Slide01.jpg />
<audio id=demo controls>
<source src=/skin/frontend/gigasavvy/quinn/audio/Slide1.mp3 type=audio/mpeg />
</audio>
</li>
<li>
<img src=http://www.quinnmedical.com/skin/frontend/gigasavvy/quinn/ppt/Slide03.jpg />
<audio id=demo controls>
<source data-src=/skin/frontend/gigasavvy/quinn/audio/Slide3.mp3 src= type=audio/mpeg />
</audio>
</li>
</ul>
</div>


In the after function i want to change data-src to src. Any help would be greatly appreciated as how to go from data-src to src


More From » jquery

 Answers
64

Renaming an attribute is not be possible. You can add new attribute and remove the old one.


Suppose there is a click event as in the following example:


$('#demo').on("click", "img", function () {
var t = this;
var source = $(t).children("source");
$source.attr({
src: $t.attr('data-src')
}).removeAttr('data-src');
}

Please modify the event according to your requirements.


[#70433] Tuesday, June 24, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
clarkulisesa

Total Points: 422
Total Questions: 93
Total Answers: 112

Location: Austria
Member since Thu, Jan 7, 2021
3 Years ago
clarkulisesa questions
Mon, Feb 24, 20, 00:00, 4 Years ago
Mon, Aug 12, 19, 00:00, 5 Years ago
;