简体   繁体   English

信用链接根据给定的脚本不起作用

[英]Credit link not work according to the given my script

Well i am coding a script which will avoid editing of credits here is my total page code: 好吧,我正在编写一个脚本,这将避免编辑学分这里是我的总页面代码:

//start the script after loading the page
$(document).ready(function(){
//get the elements from page
var urlvalue1 = document.getElementById("#mycredit").href;


//correct link
if (urlvalue1 == "http://themedaddy.net" )
{window.location.replace("#");
}
//edited link
else{
window.location.replace("http://themedaddy.net");
}

But it is not working even i have added the following html code in the body section and linked the jquery script to it. 但即使我在body部分添加了以下html代码并将jquery脚本链接到它,它也无法正常工作。

<a href="http://themedaddy444444.net" id="mycredit">ThemeDaddy</a>

According to the script it must need to get redirected as the link value is not satisfying. 根据脚本,它必须被重定向,因为链接值不满意。

wrap up the redirect code inside the click event of the anchor tag. 将锚定代码的click事件中的重定向代码包装起来。

$('a#mycredit').on('click',function(e){
  e.preventDefault();
  //correct link
  if (urlvalue1 == "http://themedaddy.net" )
    window.location.replace("#");
  else{//edited link
   window.location.replace("http://themedaddy.net");
  }
});

Its working fine you have only mistakenly written #mycredit instead of mycredit while selecting the anchor tag. 它的工作正常你在选择锚标签时只错误地写了#mycredit而不是mycredit。

$(document).ready(function(){

        var urlvalue1 = document.getElementById("mycredit").href;
        if (urlvalue1 == "http://themedaddy.net" )
        {
            window.location.replace("#");
        }
        //edited link
        else{
        window.location.replace("http://themedaddy.net");
        }

    });
    </script>
    <a href="http://themedaddy444444.net" id="mycredit">ThemeDaddy</a>

See this is working absolutely fine 看到这个工作绝对没问题

In selecting elements with getElementById we do not need to put # sign before Id :) 在使用getElementById选择元素时,我们不需要在Id之前放置#符号:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我的石英作业没有根据给定的 cron 表达式触发,而是每 10 分钟触发一次? - Why is my quartz job not getting triggered according to given cron expression, instead firing every 10 minutes? 根据给定的索引对字符串重新排序 - Reordering a String according to given indexes 根据给定序列对向量进行排序 - Sorting Vector according to given sequence 根据给定的URL加载页面 - loading a page according to given url 当尝试根据给定查询查找给定字符串中的子字符串计数时,有人能告诉我我在 Java 代码中做错了什么吗? - Can someone tell me what am I doing wrong here in my Java code when trying to find count of substrings in given string according to given queries? 为什么JRuby给我的ruby脚本提供的全局变量为空? - Why does my global variable given by JRuby to my ruby script empty? 我在 ideone 中得到了很好的结果,但 SPOJ 不接受我的解决方案。 链接如下 - I am getting fine results in ideone but SPOJ is not accepting my solution. The link is given below 根据给定的Java字符串创建字节数组 - Create a byte array according to given String In Java 根据JtextArea中给定的行号突出显示字符串 - Highlight a string according to given line number in JtextArea 根据Maven中的给定条件添加依赖项 - Add dependency according to the given condition in Maven
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM