开发者

How would I set focus on an after I remove its sibling in javascripts

I have the following code:

remove: function(child, obj){

    for (var i = 0, len = obj.compareComponents.length; i < len; i++) {
        if (obj.compareComponents[i] == child) {
            obj.compareComponents.splice(i, 1);
            break;
        }

    }

    dojo.forEach(obj.checks, function(arr){

        if (arr.number == child.id) {
            obj.states.checkMarks.empty(arr, obj, child);
        }
    });

    obj.properties.numberTaken--;
    obj.states.compare.checksFull.value.isTrue = false;
    obj.states.compare.checksFull.settings(obj);

    if (obj.properties.numberTaken < 2) {
        obj.states.compare.noChecks(obj);
    }
}  

What I am trying to as the checkboxes are unchecked and removed I开发者_开发知识库 want the focus to be set on the element to the right of it. What logic do I add to accomplish this?

Focus will set automatically if I can set the tab index of the first checkbox to 0 here is the code that was written creating the check boxes how would I modify it to set the first element's tab index to 0?

var image = arr.image[0].src;
image = '<th id="cell4' + arr.id + '" scope="col"><span class="pcChecks"><input checked="checked" type="checkbox" name="pc' + arr.id + '" id="pc' + arr.id + '" class="compare" /><label for="pc' + arr.id + '" id="" class="compare">' + '<span class="hide-fromsighted">Remove ' + temptitle + '</span>' + 'Remove</label></span><div><a href="/shop/product-detail.jsp?id=' + arr.id + '&prodName=' + temptitle + '""><img height="106" alt="' + temptitle + '"src="' + image + '"/></a></div></th>'


If all your checkboxes are the children of the same parent, then in jQuery, I'd use $(obj).next().focus().

I couldn't find a similar API in dojo :-( Which means you'll have to get the children, search yourself and then select the child with index+1.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜