Is there a way in jQuery or javascript to ignore all operations if the wrapped sets size is 0 withoug using if statement.
menu.find('a[href="#add"]'). {code that should execute only if size()>0};
I guees I would normally have to do something like this
var m = menu.find('a[href="#add"]');
if m.size()>0 { do something }
Is there a shorter way of doing this?
Edit: full code
menu.find('a[href="#add"]').attr("href","#add-metaobject")[0].innerText = "Add Object";
If the selector finds 0, it doesn’t matter what follows it.
This is the case with
$.each()tooYou could use a ternary operator, but it is really just another conditional check: