开发者

jQuery change document.location.href in input

开发者 https://www.devze.com 2023-03-17 15:25 出处:网络
is it possible to use jQuery to do that: if the body has a <div id=\"wpadminbar\"> then chang开发者_开发知识库e thedocument.location.href in this input from

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'");
0

精彩评论

暂无评论...
验证码 换一张
取 消