SEARCH !!

2010/03/24

jQuery String Replace 字串取代

ex:

html code:

<img alt="" src="images/left/21_off.jpg" />
<img alt="" src="images/left/22_off.jpg" />
<img alt="" src="images/left/23_off.jpg" />


jQuery code:

function MVHandler(){
var path = $(this).attr("src");
var newPath = path.replace("off","on");   <--("被取代","取代")
$(this).attr({src:newPath})
}

沒有留言:

張貼留言