blue coloured cta in javascript

To create a blue coloured Call To Action (CTA) button in Javascript, you can use the following code snippet:

HTML:

<button id="cta-button">Click me!</button>
43 chars
2 lines

CSS:

#cta-button {
  background-color: blue;
  color: white;
  padding: 10px 20px;
  border-radius: 5px;
  border: none;
  cursor: pointer;
}
137 chars
9 lines

Javascript:

index.tsx
const ctaBtn = document.getElementById('cta-button');
ctaBtn.addEventListener('click', function() {
  // Your code here
});
124 chars
5 lines

In the CSS code above, we set the background-color property to blue to make the button blue. We also set the color property to white to make the text white so it stands out more. We added some padding to make the button look more visually appealing, and set the border-radius property to 5px to make the edges of the button rounded. We also removed the border and set the cursor property to pointer to indicate to the user that the button is clickable.

In the Javascript code, we use the document.getElementById() method to get the button element by its ID, and then add an event listener to it that triggers when the button is clicked. You can add your own code inside the function to perform the desired action when the button is clicked.

related categories

gistlibby LogSnag