英文:
Change A Class Name to a empty name
问题
I want to change the Class name when I enter the Web
Here is the Html :
<div class="row innerbodypanel">
<form name="AGX" id="AGX" action="" method="post" autocomplete="off">
</div>
I want to change the Class (row innerbodypanel) to empty like Class=""
英文:
I'm noob and I need help.
I want to change the Class name when I enter the Web
Here is the Html :
<div class="row innerbodypanel">
<form name="AGX" id="AGX" action="" method="post" autocomplete="off">
</div>
I want to change the Class (row innerbodypanel) to a empty like Class=""
答案1
得分: 1
<!-- 开始代码片段: js 隐藏: false 控制台: false Babel: false -->
<!-- 语言: lang-js -->
使用 jQuery 的 removeClass 方法
$(".innerbodypanel").removeClass("row innerbodypanel")
<!-- 语言: lang-html -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="row innerbodypanel">
<form name="AGX" id="AGX" action="" method="post" autocomplete="off">
<!-- 结束代码片段 -->
英文:
<!-- begin snippet: js hide: false console: false babel: false -->
<!-- language: lang-js -->
use jQuery removeClass
$(".innerbodypanel").removeClass("row innerbodypanel")
<!-- language: lang-html -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="row innerbodypanel">
<form name="AGX" id="AGX" action="" method="post" autocomplete="off">
<!-- end snippet -->
答案2
得分: 0
你可以使用className
属性将其更改为空字符串(''
)。
document.querySelector('.btn').onclick = () => {
document.querySelector('.row.innerbodypanel').className = '';
}
.row {
background-color: red;
}
.innerbodypanel {
color: white;
font-weight: bold;
}
<div class="row innerbodypanel">test!</div>
<form name="AGX" id="AGX" action="" method="post" autocomplete="off"></form>
<button class="btn">click me!</button>
英文:
You could use the className
property to change it to an empty string (''
)
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
document.querySelector('.btn').onclick = () => {
document.querySelector('.row.innerbodypanel').className = '';
}
<!-- language: lang-css -->
.row {
background-color: red;
}
.innerbodypanel {
color: white;
font-weight: bold;
}
<!-- language: lang-html -->
<div class="row innerbodypanel">test!</div>
<form name="AGX" id="AGX" action="" method="post" autocomplete="off"></form>
<button class="btn">click me !</button>
<!-- end snippet -->
答案3
得分: 0
以下是翻译好的内容:
尝试像这样
<div id="A" class="row innerbodypanel">
<form name="AGX" id="AGX" action="" method="post" autocomplete="off">
</div>
$("#A").removeClass("innerbodypanel")
英文:
try like this
<div id="A" class="row innerbodypanel">
<form name="AGX" id="AGX" action="" method="post" autocomplete="off">
</div>
$("#A").removeClass("innerbodypanel")
答案4
得分: 0
$(document).ready(() => {
$("div").removeClass("row innerbodypanel");
});
这将在整个页面加载完成后移除该类。因此,在div元素加载之前,不会执行removeClass函数。
此外,您可能需要为该div添加一个id,因为“div”选择器非常通用。
英文:
$(document).ready(() =>
{
$("div").removeClass("row innerbodypanel");
});
This will remove the class when the entire page is loaded. Thus, there is no danger that the removeClass function will be executed before the div element is loaded.
Also you will maybe need an id for the div because the "div" selector is very generic.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论