I am trying to set up my webpage so that the HTML has normal links and then they change to anchor links on DOM ready.
So far i've had no luck, i'm still relatively new to using regular expressions so I have mos probably tried doing it all wrong.
Heres my jQuery code:
$(".LINKS").each(function() {
$(this).attr(
"src",
$(开发者_如何学Gothis).attr("src",replace('/\/\?page\=*?/ig', "/#"))
);
});
Any suggestions?
Links in html are done with an href
attribute on the a
node, not an src
. src
is for image url in img
nodes.
$(".LINKS").each(function() {
$(this).attr(
"href",
$(this).attr("href",replace('/\/\?page\=*?/ig', "/#"))
);
});
Besides the other guys' comments about "href", you have specified a STRING rather than a REGULAR EXPRESSION:
replace('/\/\?page\=*?/ig', "/#")
should be:
replace(/\/\?page\=*?/ig, "/#")
i.e. get rid of the apostrophes surrounding the first argument.
精彩评论