Hello,
Assume that there is an object, passed as an argument to a function. the argument name is "obj". can it be concatenated as followed?
$(obj + " .className")......
OR
$(obj + "[name='obj_name'])......
Thanks.
Hello,
Assume that there is an object, passed as an argument to a function. the argument name is "obj". can it be concatenated as followed?
$(obj + " .className")......
OR
$(obj + "[name='obj_name'])......
Thanks.
No, but you can use the filter()
method to filter out the object itself:
$(obj).filter('.className')...
$(obj).filter('[name=obj_name]')...
Or, if you want to find the children with those qualities:
$(obj).find('.className')...
$(obj).find('[name=obj_name]')...
Or, an alternative syntax to find
, giving the obj
as the context to the $()
function:
$('.className', obj)...
$('[name=obj_name]', obj)...
The second argument of your selector is the context:
$(".className", obj).each(...);
This will restrict all matches to obj
. So assuming obj
is a reference to div.parent
:
<div class="parent">
<p class="className">I'll be found</p>
</div>
<p class="className">I will NOT be found</p>