首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >这个javascript显示了由Shamweel设计,但所有的文本开始包含链接如何修复只有Shamweel包含链接

这个javascript显示了由Shamweel设计,但所有的文本开始包含链接如何修复只有Shamweel包含链接
EN

Stack Overflow用户
提问于 2020-07-31 15:47:44
回答 1查看 25关注 0票数 1

第一个代码显示Designed By Shamweel,但所有文本都是一个链接

请帮助我制作第一个代码来显示文本“设计者”,然后显示一个包含链接"Shamweel“的文本。

输出必须由(仅文本) Shamweel设计(包含链接https://www.moviesmobster.ga

我为我的模板准备了这个javascript来保护它。

代码语言:javascript
复制
$(document).ready(function() {
        if ($('#b').length == 1)
        // check if <a> exists in id="footer-post" and changes <a> address and class
        {
            $('#b a').prop('href', 'http://moviesmobster.ga/').prop('class', 'footer-3').text('Designed By Shamweel');
        }

        if ($('#b').length >= 1 && $('a.footer-3').length == 0) {
            // if link is erased it creates a new one in the same div
            $('<a>', {
                class: 'footer-3',
                text: ' Designed By Shamweel',
                href: 'https://www.moviesmobster.ga/',
            }).appendTo('#b');
        }

        if ($('#b').length == 0 && $('a.footer-3').length == 0) {
            // if div and link are erased it shows an alert and load yahoo
            alert('Template Not Purchased Or Footer Credit Is Removed')
            window.location.href = "https://apksnation.blogspot.com/p/template-not-purchased.html?m=1";
        }
    });
代码语言:javascript
复制
<script type = "text/javascript" src = "https://code.jquery.com/jquery-1.11.0.min.js"></script>


<div id='b' />

EN

回答 1

Stack Overflow用户

发布于 2020-07-31 15:56:46

你的意思是

代码语言:javascript
复制
$(function() {
  const $b = $('#b');
  if ($b.length == 1 && $('a', $b).length == 1)
  // check if <a> exists in id="footer-post" and changes <a> address and class
  {
    $('a', $b)
    .prop('href', 'http://moviesmobster.ga/')
    .prop('class', 'footer-3').text('Shamweel');
  }

  if ($b.length >= 1 && $('a.footer-3').length == 0) {
    // if link is erased it creates a new one in the same div
    $b
      .append("Designed By ")
      .append(
        $('<a>', {
          class: 'footer-3',
          text: 'Shamweel',
          href: 'https://www.moviesmobster.ga/',
        }))
  }

  if ($.length == 0 && $('a.footer-3').length == 0) {
    // if div and link are erased it shows an alert and load yahoo
    alert('Template Not Purchased Or Footer Credit Is Removed')
    window.location.href = "https://apksnation.blogspot.com/p/template-not-purchased.html?m=1";
  }
});
代码语言:javascript
复制
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<div id='b' />

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63187827

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档