Reputation: 21617
$('.modal-left img').data('src').replace('-90x67','');
Uncaught TypeError: Cannot call method 'replace' of undefined
Using the above code I am trying to remove -90x67
from the image source specified. I'm unable to do so using it, could someone assist?
Upvotes: 0
Views: 816
Reputation: 4319
You can manipulate your image attr as follows:
// To Change It
$('#test img').attr('src', 'new value');
// To Remove It
$('#test img').removeAttr('src');
Example: http://jsfiddle.net/AAyss/1/
Upvotes: 0
Reputation: 25527
try
var test=$('.modal-left img').attr('src').replace('-90x67','');
$('.modal-left img').attr('src',test);
Upvotes: 0
Reputation: 57095
Try .attr()
$('.modal-left img').attr('src').replace('-90x67','');
$('.modal-left img').prop('src').replace('-90x67','');
src
$('.modal-left img').prop('src',function(_,old){
return old.replace('-90x67','');
});
Read .data()
Upvotes: 1
Reputation: 38102
Try to use attr() here:
$('.modal-left img').attr('src').replace('-90x67','');
or prop() instead:
$('.modal-left img').prop('src').replace('-90x67','');
Your code only works if you put your image source inside data-src
attribute
<img data-src="Your image src here" src="Your img src here" />
Upvotes: 0