Как заставить всплывающее окно jQuery снова исчезать при повторном нажатии на "Approval"?
$(function() { $('a.approvals').click(function(e) { var html = '<div id="info">'; html += '<a href ="http://www.coned.com/es/specs/gas/Section%20VII.pdf" div id="ConED"><img border= "0" src="con_edison_logo.png" /></a>'; html += '<a href ="pdfs/2009_natl_grid_blue_book_web.pdf" div id="NationalGrid"><img border= "0" src="national_grid_logo.png" /></a>'; html += '<a href ="http://database.ul.com/cgi-bin/XYV/template/LISEXT/1FRAME/showpage.html?name=JIFQ.MH46473&ccnshorttitle=Gas+Boosters&objid=1079858133&cfgid=1073741824&version=versionless&parent_id=1073988683&sequence=1" div id="ULLogo"><img border= "0" src="ul_logo_a.png" /></a>'; html += '<a href ="http://license.reg.state.ma.us/pubLic/pl_products/pb_search.asp?type=G&manufacturer=Etter+Engineering+Company+Inc.&model=&product=&description=&psize=50" div id="MassGov"><img border= "0" src="massgovlogo.png" /></a>'; html += '<div id="ApprovalsTxtpopup">With the exception of the UL-listing, the above approval agencies are region-specific, should your local agencies require any further documentation other than our UL-listing, please contact ETTER Engineering Toll Free 1-800-444-1962 for further assistance.</div>'; html += '</div>'; $('#Wrapper').append(html).children('#info').hide().fadeIn(400); }, function() { $('#info').remove(); });
});
Просто используйте toggle вместо click:
toggle
click
$('a.approvals').toggle(function(e) { ...same code...
Живой тестовый кейс .
$(function() { $('a.approvals').click(function(e) { var html = '<div id="info">'; html += '<a href ="http://www.coned.com/es/specs/gas/Section%20VII.pdf" div id="ConED"><img border= "0" src="con_edison_logo.png" /></a>'; html += '<a href ="pdfs/2009_natl_grid_blue_book_web.pdf" div id="NationalGrid"><img border= "0" src="national_grid_logo.png" /></a>'; html += '<a href ="http://database.ul.com/cgi-bin/XYV/template/LISEXT/1FRAME/showpage.html?name=JIFQ.MH46473&ccnshorttitle=Gas+Boosters&objid=1079858133&cfgid=1073741824&version=versionless&parent_id=1073988683&sequence=1" div id="ULLogo"><img border= "0" src="ul_logo_a.png" /></a>'; html += '<a href ="http://license.reg.state.ma.us/pubLic/pl_products/pb_search.asp?type=G&manufacturer=Etter+Engineering+Company+Inc.&model=&product=&description=&psize=50" div id="MassGov"><img border= "0" src="massgovlogo.png" /></a>'; html += '<div id="ApprovalsTxtpopup">With the exception of the UL-listing, the above approval agencies are region-specific, should your local agencies require any further documentation other than our UL-listing, please contact ETTER Engineering Toll Free 1-800-444-1962 for further assistance.</div>'; html += '</div>'; $('#Wrapper').append(html).children('#info').hide().fadeIn(400); }, function() { $('#info').remove(); $('#Wrapper').children('#info').hide(); });