Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 936
Java Questions Avatar asked Nov 29 '25 17:11

Java Questions


1 Answers

you need to place your code in

$(document).ready(function(){
// your jquery code
});
like image 165
Pranay Bhardwaj Avatar answered Dec 01 '25 06:12

Pranay Bhardwaj



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!