[英]How to remove style content of button on click
Ok so I'm trying to make it so that whenever you click on this button it removes the style content contained within it. 好的,我正在尝试制作它,以便每当您单击此按钮时,它都会删除其中包含的样式内容。
<button id="margin" onclick="save()" class="submit" type="submit">
<style>
.enable {
margin-bottom:420px;
}
</style>
</button>
This will remove the HTML contents of button #margin when clicked. 单击后将删除按钮#margin的HTML内容。
$("#margin").on("click", function(){
$(this).html('');
});
and If you are trying to remove the CSS margin-bottom property from the .enable
element, use : 并且如果您尝试从.enable
元素中删除CSS margin-bottom属性,请使用:
$("#margin").on("click", function(){
$(".enable").css("margin-bottom", "0px");
});
Replace 0px
in above code to the original margin bottom of .enable
将上面代码中的0px
替换为.enable
的原始边距底部
$("#margin").on("click", function(){
$(this).html('');// $(this).text(''); //$(this).empty(); //$(this).find('*').remove();
});
If you want remove style from elements 如果要从元素中删除样式
$(".enable").css("margin-bottom", "0px");
$("#margin").click(function() {
$(this).html("");
});
// listen for click event on target element
$("#margin").on("click", function(){
// select `style` tag within `this` element, and remove it
$("style", this).remove();
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.