$('.modal-left img').data('src').replace('-90x67','');
Uncaught TypeError: Cannot call method 'replace' of undefinedjQuery的刪除圖像源
的一部分使用上述代碼我試圖從所指定的圖像源除去-90x67
。我無法使用它,有人可以協助嗎?
$('.modal-left img').data('src').replace('-90x67','');
Uncaught TypeError: Cannot call method 'replace' of undefinedjQuery的刪除圖像源
的一部分使用上述代碼我試圖從所指定的圖像源除去-90x67
。我無法使用它,有人可以協助嗎?
嘗試
var test=$('.modal-left img').attr('src').replace('-90x67','');
$('.modal-left img').attr('src',test);
你可以操縱你的形象ATTR如下:
// To Change It
$('#test img').attr('src', 'new value');
// To Remove It
$('#test img').removeAttr('src');
什麼是HTML是什麼樣子?因爲代碼工程http://jsfiddle.net/JK7z3/ – epascarello