JavaScripts for the Internet marketer

A wildly large introduction

JavaScripts for the Internet marketer

  1. onchange — triggers after fixing the result in the input field, after loss of focus
  2. oninput — is triggered every time the field is changed
  3. onclick — left-click on the element
  4. onload — document is downloaded
  5. onunload — closing the window (body)

If an item has its own ID

document.getElementById("ID").onclick = function() {
// Here you insert the function of your analysis system, in my case it is Amplitude
amplitude.getInstance().logEvent('Event_name_log');
};

If the item has no ID, but a class

document.getElementsByClassName("сlass")[0].onclick = function() {
amplitude.getInstance().logEvent('Event_name_log');
};
document.getElementsById("exampleID").getElementsByClassName("example-сlass")[0].onclick = function() {
amplitude.getInstance().logEvent('Event_name_log');
};

If an item has nothing

<table class="classA">
<tr><td><input type="tel"></td></tr>
<tr><td><input type="number"></td></tr>
</table>
<script>
document.getElementsByClassName("classA")[0].getElementsByTagName("input")[1].onclick = function() {
amplitude.getInstance().logEvent('Event_name_log');
};
</script>

These scripts can break the site!!!

<div class="center">
<li>button Facebook</li>
<li>button Twitter</li>
<li>button VK</li>
</div>
<script>
document.getElementsByClassName("center")[4].getElementsByTagName("li")[1].addEventListener("click", clickTwitter);
function clickTwitter() {
amplitude.getInstance().logEvent("clickTwitter");
};
</script>

--

--

UI designer who codes on a freelance basis. I’m on my way to become a UX (Product Designer) in a large company.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
azamat.design/

UI designer who codes on a freelance basis. I’m on my way to become a UX (Product Designer) in a large company.