javascript - A way to hid a div when another div is open -



javascript - A way to hid a div when another div is open -

i have 2 divs set hidden until button clicked problem don't want both of them show @ same time.

<div id="searchaddparams" class="hidden" style="color:orangered"> <label for='txtsearch'>street number:</label> <input type='text' id='txtstreetnum' /> <label for='txtsearch'>predir:</label> <input type='text' id='txtpredir' /> <label for='txtsearch'>pretype:</label> <input type='text' id='txtpretype' /> <label for='txtsearch'>street name:</label> <input type='text' id='txtstreetname' /> <label for='txtsearch'>suf dir</label> <input type='text' id='txtsufdir' /> <input type='button' id='btnsearch' onclick='searchaddress()' value='search' /> <input type='button' id='reset' onclick='resetbutton()' value='reset' /> </div> <div id="searchparparams" class="hidden" style="color:orangered"> <label for='txtsearch'>parcel id:</label> <input type='text' id='txtparcelid' /> <label for='txtsearch'>owner:</label> <input type='text' id='txtowner' /> <label for='txtsearch'>owner addr:</label> <input type='text' id='txtowneraddr' /> <label for='txtsearch'>quick refid:</label> <input type='text' id='txtquickrefid' /> <label for='txtsearch'>section township:</label> <input type='text' id='txtsecttwn' /> <input type='button' id='btnsearch2' onclick='searchparcels()' value='search' /> <input type='button' id='reset2' onclick='resetbutton2()' value='reset' /> </div>

the code i'm using hid these divs is

function unhide (divid) { var item = document.getelementbyid(divid); if (item) { item.classname = (item.classname == 'hidden') ? 'unhidden' : 'hidden'; } }

is there way hid 1 div when other clicked cause maintain getting both of divs open @ once! two divs showing @ same time

any help appreciated

you add together mutual class divs toggleable , utilize class hide selected one.

html

<div id ="searchaddparams" class="hidden group" style="color:orangered"> ... </div> <div id="searchparparams" class="hidden group" style="color:orangered"> ... </div>

javascript (jquery)

function unhide(divid) { var group= $('.group'), target = group.filter('#'+divid); if (target.length) { group.removeclass('unhidden').addclass('hidden'); target.addclass('unhidden').removeclass('hidden'); } }

javascript jquery html css html5

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -