I have an id for a
@Cawas - nice solution, but I suggest to use it not excessive, because of Regardless of that, I extended it for my needs: So if
Given the above, is it possible to find the next input:text element regardless of any other mark up in
$('*') is expensive ;-)(function( $ ){
$.fn.findNextOverall = function(sel, returnItselfIfMatched) {
if(returnItselfIfMatched && $(this).is(sel)) return $(this);
var $result = $(sel).first();
if ($result.length <= 0) {
return $result;
}
$result = [];
var thisIndex = $('*').index($(this));
var selIndex = Number.MAX_SAFE_INTEGER;
$(sel).each(function(i,val){
var valIndex = $('*').index($(val));
if (thisIndex < valIndex && valIndex < selIndex) {
selIndex = valIndex;
$result = $(val);
}
});
return $result;
};
})( jQuery );
returnItselfIfMatched is set true it returns itself, if it matches the selector itself. Useful, if you don't know, which element is calling and you are searching for exactly itself.