ticketSearchTitle
当ticketSearch
div 被隐藏时,我试图用 id 更改 h2 标题的文本颜色。但是我用来做这件事的那段代码似乎完全破坏了它(即:标题上没有指针图标,不能隐藏 div)。
分区结构:
<h2 id="ticketSearchTitle" >SEARCH</h2>
<div id="ticketSearch"><div>
完整代码:
$("h2#ticketSearchTitle").css({'cursor':'pointer', 'display':'inline'});
$("h2#ticketSearchTitle").click(function(){
$("#ticketSearch").toggle('slow');
//change h2 text to show that is is inactive
if ($("h2#ticketSearch").is(':hidden')){
$("#ticketSearchTitle").css('color','#D3D3D3')
}
});
破坏代码的 JQuery 片段:
//change h2 text to show that is inactive
if $("h2#ticketSearch").is(':hidden'){
$("#ticketSearchTitle").css('color','#D3D3D3')
}