javascript - addClass() not working -
i have bootstrap button
<button onclick="leaveopen()">test</button>
it calls custom function
function leaveopen(){ $("#rangedropdown").addclass('open'); $("#dropdownmenu2").trigger('focus').attr('aria-expanded', 'true'); }(jquery);
which should affect these elements
<div class="dropup mobilewidth mobilebottom" id="rangedropdown"> <button class="btn btn-default dropdown-toggle mobilewidth" type="button" id="dropdownmenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> ... </button> ... </div>
this part works
$("#dropdownmenu2").trigger('focus').attr('aria-expanded', 'true');
but part doesn't
$("#rangedropdown").addclass('open');
when click the test button, "dropup mobilewidth mobilebottom" lights in chrome developer tool if changed, 'open' class not added. doing wrong?
it's issue class added & it's removed.
probably bootstrap watches on focus
event , toggles open
class. if handler before bootstrap:
you:
open
addedbootstrap:
open
toggled
-> result: nothing changes
in other case class added, looking @ description chrome dev tools flashes changed it's rather issue of double changing open
class
Comments
Post a Comment