Q:

Button value is empty when use jquery selector

i am trying to select value for the selected button like the following :
html code :
<div class="span3">
            <div>DEBIT/CREDIT</div>
            <div class="btn-group" data-toggle="buttons-radio" id="investadjust-debitcredit-button">
                <button name="debitCredit" type="button" id="credit-button" class="btn active" value="CREDIT" >CREDIT</button>
                <button name="debitCredit" type="button" id="debi-button" class="btn" value="DEBIT" >DEBIT</button>
            </div>
        </div>

javascript code : 
$("#investadjust-debitcredit-button>.active").val()

but i get only empty when i printed the above line after selecting one button.
what could be the reason.

A:

As neo said you need to place your code in document ready function and use the class name of the button without spaces or you can add underscore between the words as well like this:
<button name="debitCredit" type="button" id="credit-button" class="btn_active" value="CREDIT" >CREDIT</button>

So, the code goes like:
$(document).ready(function(){
   alert("value "+$("#investadjust-debitcredit-button>.btn_active").val());
});

Good Luck!

