jQuery evaluating function call -
recently found code:
jquery(function ($) { function tog(v) { return v ? 'addclass' : 'removeclass'; } $(document).on('input', '.clearable', function () { $(this)[tog(this.value)]('x'); }).on('mousemove', '.x', function (e) { $(this)[tog(this.offsetwidth - 18 < e.clientx - this.getboundingclientrect().left)]('onx'); }).on('touchstart click', '.onx', function (ev) { ev.preventdefault(); $(this).removeclass('x onx').val('').change(); $('#table tr').css("display", "table-row"); }); });
it result in this, e. g.:
$(this)['addclass']('x');
i've never seen such syntax before. feature of jquery? or es6?
Comments
Post a Comment