我試圖在使用jQuery進行懸停時更改我的img(s)的src
屬性。但我得到一個錯誤的說法,Uncaught SyntaxError: Invalid flags supplied to RegExp constructor 'icon_history'
在js.erb文件中提供給RegExp構造函數的無效標誌
app.js.erb
var hover = <%= image_path 'icon_history-h1' %>;
var unhover = <%= image_path 'icon_history' %>;
$('img.more').hover(function(){
console.log(hover);
$(this).attr('src', hover);
},
function(){
console.log(unhover);
$(this).attr('src', unhover);
});