jQuery change document.location.href in input
is it possible to use jQuery to do that:
if the body has a <div id="wpadminbar">
then chang开发者_开发知识库e the document.location.href in this input from
<input type="button" onclick="document.location.href='/wp-login.php?action=register';" value="Forum" id="forum">
to
<input type="button" onclick="document.location.href='/forum';" value="Forum" id="forum">
if($('#wpadminbar').length > 0) {
$('#forum').attr('onClick', "document.location.href='/forum';");
}
You may want to do this in Javascript alone. Instead of changing the links there, try this:
<script type="text/javascript">
$(document).load(function() {
$("#forum").click(function() {
document.location.href="your URL";
});
});
</script>
If you can, place that in your <head>
Try
jQuery("#forum").attr("onclick", "document.location.href='/forum'");
精彩评论