嗨,我想用href ="#"和action ="#"替换页面上的所有href和action属性.有人能指出我哪里出错了;
$(document).ready(function(){
var contents = $("body").html();
contents.replace( /href=[\"'][^'\"]*[\"']/g, 'href="#"' );
contents.replace( /action=[\"'][^'\"]*[\"']/g, 'action="#"' );
});
Run Code Online (Sandbox Code Playgroud)
我也想在不使用jQuery的情况下这样做但不确定如何.
你为什么不尝试这样的事情:
$('a').attr('href','#');
$('form').attr('action','#');
Run Code Online (Sandbox Code Playgroud)