Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run function on first object?

I've got this function which runs for each instance of 'fullName':

$(xml).find("fullName").each(function(){ ... });

But there is really only ever one instance and I don't want to be using each, is there some other way to create this function without using each. Maybe just:

$(xml).find("fullName").it(function(){ ... });
like image 222
Watson Avatar asked Dec 07 '25 23:12

Watson


1 Answers

You can try something like this

var func = function(){ ... }
func.call($(xml).find("fullName")[0], args));
like image 152
Lim H. Avatar answered Dec 10 '25 12:12

Lim H.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!