I am using UIKit template. I have 2 buttons to toggle between. When I click on one button it will get a class uk-active
. But when I try to get the rel
attribute value using jQuery on form submit, it says undefined. My code is below
<button class="uk-button uk-width-1-2 uk-active" rel="0" type="button"><span class="fbaicon"></span> RENT</button>
<button class="uk-button uk-width-1-2" rel="1" type="button"><span class="fbaicon"></span> BUY</button>
And my jQuery is,
var type = $('.uk-active').attr('rel');
alert(type);
I am sure that class uk-active always exists for one of these two buttons
check whether code is executing before the DOM is loaded. Keep scripts in
$(document).ready();