Limit jQuery search scope correctly?

I came across this code and I wonder if it just limits the area or selects both elements at the same time.

container = jQuery("#test", parent.document);

jQuery("param[name=scale]", another.object)

Can anyone shed some light on this?

Edit: full example:

<script type="text/javascript">
jQuery = parent.jQuery;
container = jQuery("#test", parent.document);

another = {
    targetw: container.width()
};

function onEnd(){
  container.slideUp();
}

function onStart(){
  another.object = jQuery("object", document);

  another.w =  another.object.attr("width");
  another.h =  another.object.attr("height");
  another.targeth = Math.floor(another.targetw * another.h  / another.w);

  jQuery("div>iframe",container).width(another.targetw);
  jQuery("div>iframe",container).height(another.targeth);

  another.object.css("width", another.targetw+"px");
  another.object.css("height", another.targeth+"px");

  another.object.attr("width", another.targetw);
  another.object.attr("height", another.targeth);

  jQuery("param[name=scale]",another.object).attr("value","exactfit");

  another.object.parent().attr('style', function(i,s) { return s + 'background:none; width: '+another.targetw+'px !important; height: '+another.targeth+'px !important;' });

}
document.write('*snipped code*');
</script>

`

+4
source share
2 answers

This is apparently the context argument from the jQuery selector jQuery(selector[,context]).

From http://api.jquery.com/jquery/

Selector context

By default, selectors search the DOM starting at the root of the document. However, an alternate context can be specified for the search using the optional second parameter to the function $(). For example, to perform a search in an event handler, a search may be limited as follows:

$( "div.foo" ).click(function() {
  $( "span", this ).addClass( "bar" );
});

this, .

.find(), $( "span", this ) $( this ).find( "span" ).

+5

. DOM.

$('childNode', parent)

,

$(parent).find('childNode')

container = jQuery("#test", parent.document);

#test - , ID, jQuery('#test') , DOM.

+2

All Articles