How to delete a style in css

藏色散人
Release: 2023-01-03 09:26:02
Original
3144 people have browsed it

How to delete a style in css: First create an HTML sample file; then add a css style to the div; and finally delete one or more classes from the selected element through the "removeClass()" method.

How to delete a style in css

The operating environment of this tutorial: Windows7 system, HTML5&&CSS3 version, Dell G3 computer.

CSS to add styles and delete styles

The code is as follows:

<style type="text/css">
div{
width:100px;
height:260px;
}
div.whiteborder{
border: 2px white solid;
}
div.redDiv{
background-color: red;
}
div.blueBorder{
border: 5px blue solid;
}
</style>
Copy after login
<script type="text/javascript">
$(function(){
var $divEle = $(&#39;div:first&#39;);
$(&#39;#btn01&#39;).click(function(){
//addClass() - 向被选元素添加一个或多个类
$divEle.addClass(&#39;redDiv blueBorder&#39;);
});
$(&#39;#btn02&#39;).click(function(){
//removeClass() - 从被选元素删除一个或多个类 
$divEle.removeClass();
});
$(&#39;#btn03&#39;).click(function(){
//toggleClass() - 对被选元素进行添加/删除类的切换操作 
$divEle.toggleClass(&#39;redDiv&#39;)
});
$(&#39;#btn04&#39;).click(function(){
//offset() - 返回第一个匹配元素相对于文档的位置。
var pos = $divEle.offset();
console.log(pos);
$divEle.offset({
top:100,
left:50
});
});
})
</script>
Copy after login

How to delete a style in css

Recommended: "css Video tutorial

The above is the detailed content of How to delete a style in css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!