English 中文(简体)
页: 1 Query set var where n is ID for tabindex order?
原标题:jQuery set var where n is ID for tabindex order?
  • 时间:2012-04-15 15:13:44
  •  标签:
  • jquery

如何将以下两种文字合并为一种文字,目的是获得一种文字,为投入/选择领域制作一个表格索引牌(田地1、7、3为ID(#))?

$(function(){
var tabindex = 1;
$( input,select ).each(function() {
    if (this.type != "hidden") {
        var $input = $(this);
        $input.attr("tabindex", tabindex);
        tabindex++;
    }
});
});


$(function () {
var tab_order_positions = [1, 7, 3],
tab_order = 0;
for (var i = 0, _len = tab_order_positions.length; i < _len; i++) {
    $( #input_  + tab_order_positions[i]).attr( tabindex , ++tab_order);
}
});
问题回答
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            var tab_order_positions = [ 1 ,  7 ,  3 ]
            var tabindex = tab_order_positions.length;

            $.each(tab_order_positions, function (i, tab_order_position) {
                $( #input_  + tab_order_position).attr( tabindex , i);
            });

            $( input, select ).each(function (i) {
                var obj = $(this);

                if (obj.attr( type ) !=  hidden  && (obj.attr( id ) !== undefined && $.inArray(obj.attr( id ).split( _ )[1], tab_order_positions)) === false) {
                    obj.attr( tabindex , tabindex);
                    tabindex++;
                }
            });
        });
    </script>
</head>
<body>
    Name:<input type="text" id="input_1" /><br />
    <input type="hidden" /><br />
    <input type="hidden" /><br />
    Age:
    <input type="text" id="input_3" /><br />
    Birth:
    <input type="text" /><br />
    Test:<select>
        <option>a</option>
        <option>b</option>
    </select><br />
    Gender:
    <input type="radio" name="gender" />
    Male
    <input type="radio" name="gender" />Female
    <br />
    Vechical:
    <input type="checkbox" name="Vechical" /><br />
    <input type="checkbox" name="Vechical" /><br />
    <input type="checkbox" name="Vechical" /><br />
    <input type="hidden" />
    test1:
    <input type="text" id="input_7" /><br />
    test2:
    <input type="text" /><br />
    test3:
    <input type="text" /><br />
    test4:
    <input type="text" /><br />
</body>
</html>




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签