在这里,我们将给大家分享关于在javascript/PHP的知识,同时也会涉及到如何更有效地为什么console.log(typeof4+5)在javaScript中返回number5?、为什么pre
在这里,我们将给大家分享关于在javascript / PHP的知识,同时也会涉及到如何更有效地为什么console.log(typeof 4+5) 在javaScript 中返回number5?、为什么preventdefault/stopPropagation 在javascript 中不起作用?、在javascript、在javascript + php laravel中检查父项时自动检查子项的内容。
本文目录一览:- 在javascript / PHP
- 为什么console.log(typeof 4+5) 在javaScript 中返回number5?
- 为什么preventdefault/stopPropagation 在javascript 中不起作用?
- 在javascript
- 在javascript + php laravel中检查父项时自动检查子项
在javascript / PHP
如何解决在javascript / PHP
社区社区,
我正在寻找任何可能的方法来检测我的.jpg文件是否为Camera Raw JPEG。
我现在做什么:
在http://fotoforensics.com或https://www.metadata2go.com上测试了我的“特定”图像,发现有 文件类型JPEG, 文件扩展名为jpg, MIME类型:image / jpeg
还在javascript上检查了文件的前三个字节。有“ FF D8 FF”,所以这是jpeg文件。
还在后端站点上使用imagemagick进行了检查,并且所有数据看起来都与jpeg相同。 Adobe Photoshop将该图像检测为Camera Raw-JPEG,并在“文件信息”设置中显示图像/ tiff格式。
发现,测试的4个jpeg之间只有一个区别是:此特定图像中的图像元数据的Exif图像宽度和Exif图像高度与Image宽度和图像高度不同。其他3个文件具有相同的值。
我的问题是:
是否可以通过javascript / PHP检测Camera Raw JPEG与普通JPEG之间的差异?
感谢您的帮助,
致谢
为什么console.log(typeof 4+5) 在javaScript 中返回number5?
如何解决为什么console.log(typeof 4+5) 在javaScript 中返回number5?
为什么这段代码在js中返回number5?我想不通。 console.log(typeof 4+5)
解决方法
在 MDN
的官方文档中,明确指出:
typeof 运算符返回一个字符串,指示未计算的操作数的类型。
因此,您正在计算的内容类似于 String+Number
,它在每种情况下都会导致 String Concatenation
。请记住,当有两个操作数的加法运算并且其中一个是 String
时,它总是以字符串连接结束。
为什么preventdefault/stopPropagation 在javascript 中不起作用?
如何解决为什么preventdefault/stopPropagation 在javascript 中不起作用?
我有一个演示应用程序,其中 preventdefault/stopPropagation 。不确定我哪里做错了。使用 Jquery 它工作正常。按照以下步骤重现错误
- 运行应用程序并点击
button
。
当我输入 jQuery 代码时,它运行良好。它只在控制台上显示 ''jquery:: 1''
不显示
''jquery:: 2''
符合预期,因为我们使用了 e.preventDefault();e.stopPropagation();
jQuery(document).on(''click'',''.bclink[href*="bcid="]'',function(e){
e.preventDefault();
e.stopPropagation();
console.log(''jquery:: 1'')
})
jQuery(document).on(''click'',''.clickvideo'',function(e){
// detect .clickvideo-overlay parent to prevent spawning of additional w10 lightBoxes
console.log(''jquery:: 2'')
});
但是当我在 javascript 中使用相同的代码并单击 button
它同时控制 JS:::1
和 JS:::2
。为什么阻止默认不起作用
document.addEventListener(''click'',function(e) {
// loop parent nodes from the target to the delegation node
function handler(e){
e.preventDefault();
e.stopPropagation();
console.log("JS:::1")
}
for (var target = e.target; target && target != this; target = target.parentNode) {
if (target.matches(''.bclink[href*="bcid="]'')) {
handler.call(target,e);
break;
}
}
},false)
document.addEventListener(''click'',function(e) {
// loop parent nodes from the target to the delegation node
function handler(e){
e.preventDefault();
e.stopPropagation();
console.log("JS::: 2")
}
for (var target = e.target; target && target != this; target = target.parentNode) {
if (target.matches(''.clickvideo'')) {
handler.call(target,false)
})
这是我的代码 https://jsbin.com/riwazorine/edit?html,output
预期输出:它只显示 "JS:::1"
,因为我使用了 preventdefault 和 stopPropagation()
解决方法
在 JS 中,两个事件侦听器都附加到同一个元素 - 文档。 stopPropagation
仅停止将事件传播到 其他 元素(祖先或后代),而不是 相同 元素。
您需要 stopImmediatePropagation
,它会停止运行同一元素上的其他事件处理程序。
document.addEventListener(''click'',function(e) {
// loop parent nodes from the target to the delegation node
function handler(e) {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
console.log("JS:::1")
}
for (var target = e.target; target && target != this; target = target.parentNode) {
if (target.matches(''.bclink[href*="bcid="]'')) {
handler.call(target,e);
break;
}
}
},false)
document.addEventListener(''click'',function(e) {
// loop parent nodes from the target to the delegation node
function handler(e) {
e.preventDefault();
e.stopPropagation();
console.log("JS::: 2")
}
for (var target = e.target; target && target != this; target = target.parentNode) {
if (target.matches(''.clickvideo'')) {
handler.call(target,false)
.bcthumbnail {
width: 100px;
height: 100px;
border: 1px solid
}
<div class="bcthumbnail clickvideo bcimgadded" data-bcid="6086922094001"><a href="?bcid=6086922094001" class="bclink" title="Autonomous Infrastructure: Larry Ellison at Oracle OpenWorld 2019"><button class="vjs-big-play-button"></button>button</a></div>
此外,您可以使用 for
而不是您的 .closest
厕所,它更干净。
document.addEventListener(''click'',(e) => {
if (e.target.closest(''.bclink[href*="bcid="]'')) {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
console.log("JS:::1")
}
})
document.addEventListener(''click'',function(e) {
if (e.target.closest(''.clickvideo'')) {
console.log("JS::: 2")
}
})
.bcthumbnail {
width: 100px;
height: 100px;
border: 1px solid
}
<div class="bcthumbnail clickvideo bcimgadded" data-bcid="6086922094001"><a href="?bcid=6086922094001" class="bclink" title="Autonomous Infrastructure: Larry Ellison at Oracle OpenWorld 2019"><button class="vjs-big-play-button"></button>button</a></div>