用JavaScript代码 制作书签

在浏览器书签栏空白处右击,新建标签,然后名字自取,网址处粘贴代码.

 

 

代码总体结构是 "JavaScript: + 自运行函数".

以下这段案例是修改页面CSS的代码:

JavaScript:
(function(){
 var table = document.querySelector("table");
    table.style.borderCollapse = "collapse";
    table.style.fontFamily = "微软雅黑";
    table.style.fontWeight = "bold";
    table.style.fontSize = "14px";
    table.style.border = "4px solid black";
    var td = table.querySelectorAll("td");
    td.forEach(function (item) {
        item.style.borderCollapse = "collapse";
        item.style.padding = "0px";
        item.style.paddingLeft = "5px";
        item.style.border = "4px solid black";
    })
})()

 

这里顺带写一下,CSS样式里面,如 font-Size 这种带连接符"-" 的,要用驼峰表示法来表示 : fontSize 

 

posted @ 2022-07-25 16:06  一曲轻扬  阅读(815)  评论(0)    收藏  举报