on click listener code example
Example 1: button listener android
public class MyActivity extends Activity {
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.my_layout_id);
final Button button = (Button) findViewById(R.id.my_cool_button);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
}
});
}
}
Example 2: event listener javascript
const element = document.querySelector(".class__name");
element.addEventListener("click", () => {
console.log("clicked element");
});
Example 3: event listener javascript
document.getElementById("myBtn").addEventListener("click", displayDate);