I'm using jquery function attr()
to fetch a input element' custom attribute. However this function returns undefined
in Chrome. I tried to print this element and the result is:
[prevObject: o.fn.init[1], context: document, selector: "input[name="money",uid="1"]", jquery: "2.1.0", constructor: function…]
Following are my js codes:
$('.panel').each(function(index, element) {
var uid = $(this).attr('uid');
console.log($(this));
var moneyMinusBtn = $(this).find('.btn-money-minus')[0];
var moneyPlusBtn = $(this).find('.btn-money-plus')[0];
var moneyInput = $(this).find('input[name="money"]')[0];
console.log($('input[name="money",uid="'+uid+'"]').attr('uid'));
}
HTML code:
<input type="number" class="form-control" name="money" value="<?php echo $node['money'] ?>" uid="1" />