Get the App
SLTechnology News&Howtos  ›  Development  › 

How jquery hides span elements

Shulou Source: shulou.com Published: 2022-06-01 06:52:58 10月03日 Update

Xiaobian to share with you how jquery hides the span element, I believe most people do not know how, so share this article for your reference, I hope you have a lot of harvest after reading this article, let's go to understand it together!

Hiding methods: 1. Use "$("span").hide();" statement to hide;2. Use "$("span").toggle(false);" statement to hide;3. Use "$("span").css ('display ','none');" statement to hide.

本教程操作环境:windows7系统、jquery1.10.2版本、Dell G3电脑。

jquery隐藏span元素

在jquery中,有多种方法可以隐藏span元素。

hide()

toggle(false)

css('display','none')

attr('style','display:none')

示例:

这是一个标题 这是一个span元素。

这是一个p元素。

隐藏span元素

jq代码:

//方法1 $(document).ready(function(){ $("button").click(function(){ $("span").hide(); }); });//方法2 $(document).ready(function(){ $("button").click(function(){ $("span").toggle(false); }); });//方法3 $(document).ready(function(){ $("button").click(function(){ $("span").css('display','none'); }); });//方法4 $(document).ready(function(){ $("button").click(function(){ $("span").attr('style','display:none'); }); });

效果是一样的:

That's all for "how jquery hides span elements." Thanks for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!

Tags: Elements methods articles statements this is content not much code many most effects tutorials more titles versions environment computers knowledge examples systems Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia macOS Xiaomi Apple OPPO Reno