javascript - How to change the order of elements (radio buttons) returned by jQuery selector? -
i have table radio buttons.
in jquery collection, c = $('input[name=mybuttons]'), them rows, c[0] 1 in top left cell.
how change order, that, say, c[0] cell, or arrow keys go, say, columns , not rows; tab brings specific button rather top left, , right arrow traverse buttons in specific order , not left-to-right?
for checkboxes , tab key, achieve tabindex. how achieve similar effect radio buttons , right key: specify in html in order right key should traverse them?
fiddle: http://jsfiddle.net/2u30u7fp/3/ tab key iterate in desired order, right , left keys don't.
here are: use .insertbefore() or .insertafter(). in example, if choose radio button, button go first in group.
$(document).on("change", "input[name='sex']", function() { var index = $("input[name='sex']").index($(this)); console.log(index); if (index != 0) { $(this).parent('div').insertbefore("div:first"); } }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div> <input type="radio" name="sex" value="male">male</div> <div> <input type="radio" name="sex" value="female">female</div> hope helps.
Comments
Post a Comment