Trigger fb:login-button with other button Javascript

button, facebook, facebook-javascript-sdk, facebook-login

Solution

Answer by @Lix in code:

<input type="submit" onclick="FB.login()"/>

Problem

I want to trigger the `fb:login-button`: ``` <fb:login-button show-faces="true" width="200" max-rows="1"></fb:login-button> ``` with a second button. Why? I can't adjust the css of the Facebook and I want a fancy button with a custom image to replace it. My big problem is that I don't know what's the ID of the FB-button, and I can't give it one. My wrong code: ``` <script> function Ffirst() { alert("first"); $("fb:login-button").click(); //$("fb:login-button").trigger("click"); //doesn't work eiter } </script> <input type="submit" onclick="Ffirst()" name="savebutton" id="first" /> <fb:login-button show-faces="true" width="200" max-rows="1"></fb:login-button> ``` FTR: This is what happens when I press `the fb:login-button` ``` FB.Event.subscribe('auth.authResponseChange', function(response) { // Here we specify what we do with the response anytime this event occurs. if (response.status === 'connected') { testAPI(); } } else if (response.status === 'not_authorized') { FB.login(); } else { FB.login(); } }); // Load the SDK asynchronously (function(d){ var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0]; if (d.getElementById(id)) {return;} js = d.createElement('script'); js.id = id; js.async = true; js.src = "//connect.facebook.net/en_US/all.js"; ref.parentNode.insertBefore(js, ref); }(document)); ```

Original source