Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
删除Wordpress(Javascript)中特定标记上的样式_Javascript_Html_Wordpress_Contains_Getelementsbytagname - Fatal编程技术网

删除Wordpress(Javascript)中特定标记上的样式

删除Wordpress(Javascript)中特定标记上的样式,javascript,html,wordpress,contains,getelementsbytagname,Javascript,Html,Wordpress,Contains,Getelementsbytagname,在Wordpress中,位于标记内,如下所示 因为,您不能用纯CSS覆盖它,必须使用JavaScript 这是一种非常简单的方法,如果您愿意,可以通过优化或抽象许多逻辑来使用jQuery: function removeAnchorBorder() { var anchorWithPic = document.getElementsByTagName("a"); if (anchorWithPic.contains(img) = true) { anchorWithPic.sty

在Wordpress中,
位于
标记内,如下所示

因为,您不能用纯CSS覆盖它,必须使用JavaScript

这是一种非常简单的方法,如果您愿意,可以通过优化或抽象许多逻辑来使用jQuery:

function removeAnchorBorder() {
  var anchorWithPic = document.getElementsByTagName("a");
  if (anchorWithPic.contains(img) = true) {
    anchorWithPic.style.border = "none";
}
add_filter("the_content", "removeAnchorBorder");
这是一个直观的例子

还请注意,
.forEach()
可能在所有浏览器中都不可用,而
数组切片
引用只是将所选节点列表转换为实际可编辑数组的一个技巧。

因为,您不能用纯CSS覆盖它,必须使用JavaScript

这是一种非常简单的方法,如果您愿意,可以通过优化或抽象许多逻辑来使用jQuery:

function removeAnchorBorder() {
  var anchorWithPic = document.getElementsByTagName("a");
  if (anchorWithPic.contains(img) = true) {
    anchorWithPic.style.border = "none";
}
add_filter("the_content", "removeAnchorBorder");
这是一个直观的例子


还请注意,
.forEach()
可能在所有浏览器中都不可用,而
数组切片
引用只是将所选节点列表转换为实际可编辑数组的一个技巧。

为什么不在CSS中覆盖它呢?可能还不够清楚。我有
链接
,底部有点边框,但图片下方也有边框,也就是
。因此,我必须删除
的边框,该边框内有
。我无法设置
img{border:none;}
,因为边框来自
标记。对于这种有条件的情况,有没有办法使用CSS?您不能在带有边框的锚点上添加一个特定的类吗?然后只在那个类上加上边界?为什么不在CSS中覆盖它呢?也许还不够清楚。我有
链接
,底部有点边框,但图片下方也有边框,也就是
。因此,我必须删除
的边框,该边框内有
。我无法设置
img{border:none;}
,因为边框来自
标记。对于这种有条件的情况,有没有办法使用CSS?您不能在带有边框的锚点上添加一个特定的类吗?然后把边界只放在那个类上?
var withoutImg = Array.prototype.slice.call(document.querySelectorAll('a'),0); 
var withImg = Array.prototype.slice.call(document.querySelectorAll('a img'),0);

withoutImg.forEach(function(node){ 
  node.style.borderStyle = "dotted";
});

withImg.forEach(function(node){ 
  node.parentElement.style.borderStyle = "none";
});