On the page there are a lot of such input and all without ID
function doAdd(btn) { var c = getCookie('m_ids'); if (c) { var a = c.split(','); for (i = 0; i < a.length; i++) { if (a[i] == btn.alt) { alert(''); return false; } } a.push(btn.alt); setCookie('m_ids', a.join(','), '', '/'); } else { setCookie('m_ids', btn.alt, '', '/'); } order('cost', 'alt'); ordc(); return false; } <input class="button btn js-add-to-cart" alt="^[$id]" value="Добавить в заказ" readonly="readonly" onclick="return doAdd(this)"> How to replace onclick="return doAdd(this)" with $('body').on('click', smth, function(e)