RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-332911

InstincT's questions

Martin Hope
InstincT
Asked: 2020-06-05 21:45:09 +0000 UTC

如何在子元素上禁用父事件?

  • 1

let offsetX;
let offsetY;
let parent = document.getElementById("parent");

function moveParent() {
  parent.addEventListener("dragstart", function(event) {
    offsetX = event.offsetX;
    offsetY = event.offsetY;
  })

  parent.addEventListener("dragend", function(event) {
    parent.style.top = (event.pageY - offsetY) + "px";
    parent.style.left = (event.pageX - offsetX) + "px";
  })
}
moveParent();
#parent {
  background-color: gray;
  height: 200px;
  width: 200px;
  position: absolute;
  top: 0;
  left: 0;
}

#son {
  background-color: yellow;
  height: 100px;
  width: 100px;
  position: absolute;
  top: 0;
  right: 0;
}
<div id="parent" draggable="true">
  <div id="son"></div>
</div>

如您所见,代码中有一个 Parent ,其中有 Son 元素。有必要使“抓取”Son Parent 元素不移动,而仅在抓取自身时才移动,即灰色的东西(单击“运行代码”)。

javascript
  • 1 个回答
  • 10 Views
Martin Hope
InstincT
Asked: 2020-04-18 23:56:52 +0000 UTC

如何在 PyCharm 中运行代码/文件?

  • 1

我在PyCharm中创建了一个项目,在文件夹中创建了一个文件,至少编写了一些代码(例如print("hello))。我想运行它,我按"Run" -> "Run...",然后呢?只有“编辑配置”,仅此而已。我该怎么办?

python
  • 1 个回答
  • 10 Views
Martin Hope
InstincT
Asked: 2020-04-22 22:28:46 +0000 UTC

我的代码有效吗?(本地存储,加载,卸载)

  • 1

我的代码有效吗?不能理解。显然不是,但也许我错了。

var progressLine = document.getElementById('progressLine');
localStorage.setItem('progressLineNumberLocal', progressLine.value);

function plus1() {
    progressLine.value += 1;
}

function plus5() {
    progressLine.value += 5;
}

function minus1() {
    progressLine.value -= 1;
}

function minus5() {
    progressLine.value -= 5;
}

function fun1() {
    progressLine.value = localStorage.getItem('progressLineNumberLocal');
}

function fun2() {
    localStorage.setItem('progressLineNumberLocal', progressLine.value);
}
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>
            Document
        </title>
    </head>
    <body onload="fun1()" unload='fun2()'>
        <button id='but1' onclick="plus1()">+1</button>
        <button id='but2' onclick="plus5()">+5</button>
        <button id='but3' onclick="minus1()">-1</button>
        <button id='but4' onclick="minus5()">-5</button>
        <br>
        <progress min='0' max='100' value='0' id='progressLine'></progress>
        <script src='script.js'></script>
    </body>
</html>

以及如何解决?我认为您理解此处代码的含义,PROGRESS 中用于增加和减少数字的按钮(并且它有效),但我希望它是当您在条带中键入 50 并退出站点时。再输入一次,这里已经有50分了

javascript
  • 1 个回答
  • 10 Views
Martin Hope
InstincT
Asked: 2020-04-09 00:42:36 +0000 UTC

如何改变链接的外观?

  • -1

吃了它

<a href="#" id="a1">1</a>

和

<a href="#" id="a2">2</a>

如何在CSS中编写使其对正常状态下的第一个链接有效,从而没有下划线,颜色为黑色。而对于第二个,以通常的形式,一切都是标准的,但是当你将鼠标悬停在它上面时,假设它变成了绿色?

css
  • 1 个回答
  • 10 Views
Martin Hope
InstincT
Asked: 2020-04-06 16:51:49 +0000 UTC

如何编写包含文件的路径?

  • 0

想象有一个“项目”文件夹。它还有三个文件夹,例如“HTML”、“CSS”和“javaScript”。在“HTML”文件夹中有一个 index.html 文件,在“javaScript”文件夹中有一个 code.js 文件。在“script”标签的(index.html)“src”属性中应该写什么来包含code.js文件?或者你不能这样做,你需要它是这样的:一个包含 index.html 文件的文件夹,其中一个包含 code.js 文件的文件夹

файловая-система
  • 1 个回答
  • 10 Views
Martin Hope
InstincT
Asked: 2020-04-06 11:37:09 +0000 UTC

根据设备更改应用程序中窗口的大小

  • 0

Play Market 中有应用程序(不仅如此,让我们来看看吧)(在 PC 上这些是网站)。下载它们的设备具有不同的屏幕尺寸。告诉我如何更改 javaScript 中“工作”区域的大小(通常在网站上)。一个人从 PC 上查看该站点,一切看起来都很好且正常,而另一个人从电话上查看该站点,一切都出错了。

javascript
  • 1 个回答
  • 10 Views
Martin Hope
InstincT
Asked: 2020-04-05 20:57:43 +0000 UTC

代码中的错误:没有看到变量(喜欢)

  • 1
var displayOfAll = document.getElementById("displayOfAll");
var playButton = document.getElementById("playButton");
var playButtonShadow = document.getElementById("playButtonShadow");
var playButtonPosX = 300;
var playButtonPosY = 350;
var playButtonMovingUpPosY = 350;
var playButtonHeightWhenMovingUp = 100;
var playButtonFontSize = 500;
var moneyNum = 0;
var addMoneyButtonPlus = '+';
var moneyToAdd = 1;
function Play() {
playButton.style.left = playButtonPosX+"px";
playButton.style.top = playButtonPosY+"px";
displayOfAll.removeChild(playButtonShadow);
if (playButtonMovingUpPosY <= 350) {
    var moveUp = setInterval(function movingUp() {
        if (playButtonMovingUpPosY <= 100) {
            if (playButtonMovingUpPosY <= 0) {
            clearInterval(moveUp);
            displayOfAll.removeChild(playButton);
            Main();
            }
            playButtonHeightWhenMovingUp -= 2;
            playButton.style.height = playButtonHeightWhenMovingUp+"px";
            playButtonMovingUpPosY -= 2;
            playButton.style.top = playButtonMovingUpPosY+"px";
            if (playButtonFontSize <=  300) {
                if (playButtonFontSize <= 0) {
                    playButtonFontSize = 0;
                } else {
                    playButtonFontSize -= 300;
                    playButton.style.fontSize = playButtonFontSize+"%";
                }
            } else {
                playButtonFontSize -= 5;
                playButton.style.fontSize = playButtonFontSize+"%";
            }
        } else {
            playButtonMovingUpPosY -= 2;
            playButton.style.top = playButtonMovingUpPosY+"px";
        }
    }, 1)
}
}
function Main() {
var moneyDiv = document.createElement("div");
moneyDiv.style = "margin:0px;padding:0px;position:absolute;height:100px;width:200px;background-color:green;font-size:500%;text-align:center;top:100px;left:275px;z-index:10;";
displayOfAll.appendChild(moneyDiv);
moneyDiv.innerHTML = "0";
var addMoneyButton = document.createElement("div");
addMoneyButton.style = "margin:0px;padding:0px;position:absolute;height:100px;width:200px;background-color:green;font-size:500%;text-align:center;top:500px;left:275px;z-index:10;";
addMoneyButton.innerHTML = addMoneyButtonPlus;
addMoneyButton.onclick = addMoney;
displayOfAll.appendChild(addMoneyButton);
}
function addMoney() {
moneyNum += moneyToAdd;
moneyDiv.innerHTML = moneyNum;
}

在倒数第二行(“moneyDiv.innerHTML = moneyNum;”)中,浏览器编辑器给出错误“Uncaught ReferenceError: moneyDiv is not defined at HTMLDivElement.addMoney”这里有什么问题?为什么他看不到变量?

javascript
  • 1 个回答
  • 10 Views
Martin Hope
InstincT
Asked: 2020-04-05 17:02:23 +0000 UTC

未显示更改的变量

  • 1

有一个 DIV 元素具有调用此函数的 onclick 属性

function addMoney() {
moneyNum += moneyAdding;
moneyDiv.innerHTML = moneyNum;}

在此函数的第三行中,写入“替换”先前的值并写入新值,但这不会发生。为什么?这个函数之前的代码已经有:

var moneyNum = 0;
moneyDiv.innerHTML = moneyNum;

这个零是输出的,但不是新的数字。请告诉我该怎么做。

javascript
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5