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', '');
});
}
οnfοcus="$(this).siblings().removeClass('hover');"
<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>
function expand(id){
var bool=$("#"+id).attr('aria-expanded');
$('#'+id).click(function(event) {
bool=!bool;
$("#"+id).attr('aria-expanded',bool);
window.οnkeydοwn=function(event) {
event=event||window.event;
if(event.keyCode==13){
bool=!bool;
$("#"+id).attr('aria-expanded',bool);
}
};
});
}
expand('aa');
expand('bb');
expand('cc');
expand('dd');
<div role="tab" aria-expanded="false" tabindex="0" id="aa" οnkeydοwn="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>
<div role="tab" aria-expanded="true" tabindex="0" id="aa" οnkeydοwn="if(event.keyCode==13)this.click($(this).attr('aria-expanded','true'));">
<h4>USA to Thailand</h4>
<p><b>From</b>$605</p>
</div>
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 = '';
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;
}
}
}
οnkeydοwn="expand(event,'thailand')"
οnkeydοwn="expandtab(event,'baggage')"