jquery显示、隐藏div的方法

时间:2023-03-10 01:52:34
jquery显示、隐藏div的方法
$("#top_notice").css("display", "block");//第1种方法
//$("#top_notice").attr("style", "display:block;");//第2种方法
//$("#top_notice").show();//第3种方法

  1.给元素换class,来实现隐藏div,前提是换的class样式定义好了隐藏属性

$("#sendPhoneNum").attr("class", "n_input3");

  1.2给元素设置style属性

$("#top_notice").attr("style", "display:block;");

  2.通过jquery的css方法,设置div隐藏

$("#sendPhoneNum").css("display", "none");

  3.通过jquery的show()、hide()方法,设置div隐藏

$("#textDiv").show();//显示div
$("#imgDiv").hide();//隐藏div