📜  如何使用 jquery 设置 css 样式 - CSS 代码示例

📅  最后修改于: 2022-03-11 14:47:50.133000             🧑  作者: Mango

代码示例4
--------------------------------------------------------------
Method:
    const element = $("#element")
    function update_change_css(field, val)
    {
        element.css(field, val)
    }



Usage:
    const element = $("#element")
    function update_change_css(field, val)
    {
        element.css(field, val)
    }

    update_change_css("display", "block")
    update_change_css("background-color", "red")
    update_change_css("width", "100%")
    update_change_css("color", "aqua")
--------------------------------------------------------------
OR
--------------------------------------------------------------
Method:
    $('#element').css("property", "property value")



Usage:
    $('#element').css("color", "red")
    $('#element').css("background-color", "blue")
    $('#element').css("font-size", "30px")
--------------------------------------------------------------
OR
--------------------------------------------------------------
Method:
    const element = $("#element")
    function update_change_css(val)
    {
        element.css("color", val)
    }



Usage:
    const element = $("#element")
    function update_change_css(val)
    {
        element.css("color", val)
    }

    update_change_css("black")
    update_change_css("red")
    update_change_css("blue")
    update_change_css("aqua")
--------------------------------------------------------------