function expand(ele){
$('#'+ele).focus(function() {
/* Act on the event */
$(this).siblings().removeClass('hover');
$(this).siblings().find('.cates').attr('class', 'cates');
$(this).siblings().find('.cates').css('height', '');
});
}css
onfocus="$(this).siblings().removeClass('hover');"
this
<div role="tab" aria-expanded="false" tabindex="0" id='aa'>dsfsdfsdf</div>
<div role="tab" aria-expanded="false" tabindex="0" id='bb'>dsfsdfsdf</div>
<div role="tab" aria-expanded="false" tabindex="0" id='cc'>dsfsdfsdf</div>
<div role="tab" aria-expanded="false" tabindex="0" id='dd'>dsfsdfsdf</div>rem
function expand(id){
var bool=$("#"+id).attr('aria-expanded');
$('#'+id).click(function(event) {
bool=!bool;
$("#"+id).attr('aria-expanded',bool);
window.onkeydown=function(event) {
event=event||window.event;
if(event.keyCode==13){
bool=!bool;
$("#"+id).attr('aria-expanded',bool);
}
};
});
}io
expand('aa');
expand('bb');
expand('cc');
expand('dd');event
<div role="tab" aria-expanded="false" tabindex="0" id="aa" onkeydown="if(event.keyCode==13)this.click(var bool=$(this).attr('aria-expanded');bool=!bool;$(this).attr('aria-expanded','bool'));">
<h4>USA to Thailand</h4>
<p><b>From</b>$605</p>
</div>function
<div role="tab" aria-expanded="true" tabindex="0" id="aa" onkeydown="if(event.keyCode==13)this.click($(this).attr('aria-expanded','true'));">
<h4>USA to Thailand</h4>
<p><b>From</b>$605</p>
</div>class
function expand(event, id) {
event = event || window.event;
if (event.keyCode == 13||event.which==13) {
var bool = $("#" + id).attr('aria-expanded');
if (bool == 'true') {
$("#" + id).attr('aria-expanded', false);
} else {
$("#" + id).attr('aria-expanded', true);
}
$("#" + id).click();
}
}
var tab = '';cli
function expandtab(event, id) {
if (tab == id) {
return;
} else {
event = event || window.event;
if (event.keyCode == 13||event.which==13) {
if (tab != '') {
$("#" + tab).attr('aria-expanded', false);
}
$("#" + id).attr('aria-expanded', true);
$("#" + id).click();
tab = id;
}
}
}
onkeydown="expand(event,'thailand')"tab
onkeydown="expandtab(event,'baggage')"di