小编Hwe*_*nde的帖子

将div的内容复制到另一个div中

我的网站上有两个div.它们共享相同的css属性,但其中一个拥有24个其他div.我想将所有这24个div复制到另一个div中.这是它的样子:

<div id="mydiv1">
    <div id="div1">
    </div>
    </div id="div2>
    </div>
    //and all the way up to div 24.
</div>

<div id="mydiv2">
</div>
Run Code Online (Sandbox Code Playgroud)

我希望在页面加载时将mydiv1中的所有24个div复制到mydiv2中.

提前致谢

html javascript

13
推荐指数
2
解决办法
5万
查看次数

检测浏览器缩放级别

我有一个带有边界权属性的 div。当我的网站缩小时,div 大小会适应,但边框仍将保持相同大小。这会导致 div 移出其父级。有没有办法检测缩放级别?这样我就可以根据缩放改变大小。如果是这样,那又如何?

提前致谢

html javascript css

5
推荐指数
1
解决办法
6621
查看次数

将div拉伸至A4尺寸

我有以下功能,效果很好.

<script type="text/javascript">
function printDiv(printpage)
{
var headstr = "<html><head><title></title></head><body>";
var newstr = document.all.item(printpage).innerHTML;
var oldstr = document.body.innerHTML;
document.body.innerHTML = headstr+newstr;
window.print();
document.body.innerHTML = oldstr;
return false;
}
</script>
Run Code Online (Sandbox Code Playgroud)

但是我的div大约是纸张尺寸的一半.有没有办法在调用函数时将div拉伸到完整的纸张尺寸?

html javascript

4
推荐指数
1
解决办法
1万
查看次数

检查一次是否可以看到多个div

我一直在使用以下代码来检查div是否可见:

if ($("#monday").is(':visible')) {
    document.getElementById('scheduleitem1').style.width = 540;
    $("#scheduleitem1").show();                     
}
Run Code Online (Sandbox Code Playgroud)

该代码运行良好.但是,我想检查一次是否可以看到多个div中的一个.

我尝试过以下不起作用的代码:

if ($("#monday" || "#tuesday").is(':visible')) {
    document.getElementById('scheduleitem1').style.width = 540;
    $("#scheduleitem1").show();                     
}
Run Code Online (Sandbox Code Playgroud)

if ($("#monday", "#tuesday").is(':visible')) {
    document.getElementById('scheduleitem1').style.width = 540;
    $("#scheduleitem1").show();                     
}
Run Code Online (Sandbox Code Playgroud)

那么如果我想检查一个多个div中的一个是否同时可见,我该怎么办?

html javascript jquery

2
推荐指数
1
解决办法
1777
查看次数

如果选项值可见

如果可以看到特定的选择选项,我想要执行一个函数.我试过以下代码:

if ($(("#daychoise option[value='monday2']").is(':visible'))) {

}
Run Code Online (Sandbox Code Playgroud)

这不起作用,我在控制台中收到以下错误:

未捕获的TypeError:对象#daychoise选项[value ='monday2']没有方法'是'

那么如何检查选择选项是否可见?

提前致谢

html javascript jquery

1
推荐指数
1
解决办法
1478
查看次数

如何将Unicode特殊字符转换为html实体?

我有以下字符串:

$string = "? This is some text ?";
Run Code Online (Sandbox Code Playgroud)

我想将其转换为html实体:

$string = "&#9733; This is some text &#9733;";
Run Code Online (Sandbox Code Playgroud)

每个人都在写的解决方案:

htmlentities("? This is some text ?", "UTF-8");
Run Code Online (Sandbox Code Playgroud)

但是htmlentities无法将所有unicode转换为html实体.所以它只是给我与输入相同的输出:

? This is some text ?
Run Code Online (Sandbox Code Playgroud)

我也尝试将这个解决方案与两者结合起来:

header('Content-Type: text/plain; charset=utf-8');
Run Code Online (Sandbox Code Playgroud)

和:

mb_convert_encoding();
Run Code Online (Sandbox Code Playgroud)

但这打印和空结果,根本不转换或错误地将星星转换为:

&Acirc;
Run Code Online (Sandbox Code Playgroud)

如何将★和所有其他unicode字符转换为正确的html实体?

php unicode utf-8 html-entities

1
推荐指数
1
解决办法
1164
查看次数

标签 统计

html ×5

javascript ×5

jquery ×2

css ×1

html-entities ×1

php ×1

unicode ×1

utf-8 ×1