Osmany González Osmany González - 4 months ago 23
Javascript Question

OnClick on button with title

I need when click in a button with title = "Like" redirect to other page in javascript.

<button class="button-like button button-medium button-responsive" aria-describedby="tooltip-94" tabindex="0" title="Like">Like</button>

Answer

Make use of $('button[title="Like"]') selector and call onclick on it.

$(function(){

  $('button[title="Like"]').on('click', function(){
    window.location.href = 'https://www.google.com'
  });
})
Comments