In jquery, you can use the css() method to control css, add the "display: none;" style to the element, and then delete the element; the syntax format is "$("element").css(" display", "none");".
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
In jquery, you can use the css() method to control css, add the "display: none;
" style to the element, and then delete the element
css() Method returns or sets one or more style properties of the matched element.
Implementation code:
<!DOCTYPE html> <html> <head> <script src="js/jquery-1.10.2.min.js"></script> <script> $(document).ready(function() { $("#btn").click(function() { $("#box").css("display", "none"); }); }); </script> </head> <body> <div>测试元素</div> <div id="box">测试box元素</div> <div>测试元素</div><br> <button id="btn">点击删除box元素</button> </body> </html>
Related video tutorial recommendations: jQuery tutorial (video)
The above is the detailed content of How jquery controls css to delete elements. For more information, please follow other related articles on the PHP Chinese website!