在jquery中同样也可以像css文件中那样定义html的样式。 先说如何获取html标签的某个css属性值吧 获取方法:$(select).css(name) select是要获取的对象,name是css的属性名称。 例: $("div").css("color");    //获取div的color值 如何设置html标签的某个css属性值呢? 有两个方法 一.  $(select).css(name,value) :select是要获取的对象,name是css的属性名称,value是css的属性值。 例: $("div").css("color","#FFF"); 二.   $(select).css({name1:value1,name2:value2}) :select是要获取的对象,name1,name2是css的属性名称,value1,value2是css的属性值,设置多个属性用逗号分隔。 例: $("div").css({color:"#ff0211",background-image:"#ff0011"}); 注:在使用jquery中获取样式的背景时,要注意,不要用css('background')这样方式,而要用css('background-color')获取背景颜色或用css('background-image')获取背景图片,而设置背景时就没有问题,我在做项目的过程中就遇到这种问题,花了很长时间才找到原因,所以在这里提醒各位。

Words translated by CCJK


Request a call or contact us


    Call for professional assistance


    Click Here to leave us a message and be as detailed as possible.

We are Certified

Our Client Satisfaction

rating for previous quarte

    Inquiry Form

    Please take few minutes to fill
    inquiry form and get Free Quote

    Request a Call

    Click to receive Free Call, Our
    Representative will contact you

    Leave a Message

    Please leave us a message and
    be as detailed as possible

Over 95% of our clients recommend our language services to others

Copyright © CCJK Technologies Co., Ltd. 2000-2017. All rights reserved.