Hi. I have a bunch of images on a page that are contained within a div with a class of content-block like this:
<div class="content-block">
<img src="../images/path/path/image.jpg" alt="blah" title="blah" />
<img src="../images/path/path/image.jpg" alt="blah" title="blah" />
<img src="../images/path/path/image.jpg" alt="blah" title="blah" />
<img src="../images/path/path/image.jpg" alt="blah" title="blah" />
<img src="../images/path/path/image.jpg" alt="blah" title="blah" />
</div>
I am loading this html into a div via ajax. When I load it in I need to remove the "../" before the image path, after it loads in so the path remains correct. Can this be done with JQuery? Many thanks in advance.
MY JQUERY CODE FOR LOADING IN THE HTML:
$(document).ready(function() {
$('.projects a').click(function(event) {
$('#work').load(this.href + ' #loadwork');
event.preventDefault();
});
});
EDIT
$(document).ready(function() {
$('.projects a').click(function(event) {
$('#work').load(this.href + ' #loadwork', function(){
$('.content-block>img').each(function(){
$(this).attr('src',$(this).attr('src').replace('../',''));
});
});
event.preventDefault();
});
});