开发者

How to get value of pressed button (jQuery UI button-checkboxes)

Hello like in topic how get value(text) from checked buttons ? Here is my example:

<div id="wyposazenie" style="display: table-row">
    <开发者_运维知识库label>Wyposażenie dodatkowe:</label>
    <input type="checkbox" id="check1" /><label for="check1">Projektor</label>
    <input type="checkbox" id="check2" /><label for="check2">Odtwarzacz CD</label>
    <input type="checkbox" id="check3" /><label for="check3">Inne</label>
</div>

how get example value "Projektor" when button #check1 is checked ? And how get more than one value if checked more than one button


You can use .map() for this:

var arr = $("#wyposazenie :checkbox:checked").map(function() {
            return $(this).next().text();
          }).get();

Just run this whenever you need, it'll get an array of all the checked <input> elements' labels.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜