Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8033517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:43:27+00:00 2026-06-05T01:43:27+00:00

Which of the following ways is a better way to call a js function

  • 0

Which of the following ways is a better way to call a js function from an a tag?

<a href="javascript:someFunction()">LINK</a>

OR

<a href="#" onclick="someFunction();" return false;">LINK</a>

I have seen this question here, but it says <span onclick="someFunction()"> is a better option. But due to some reasons I have to use <a> links.

EDIT: I am looking for a cross browser & cross platform solution which should work on androids & iPads too.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T01:43:28+00:00Added an answer on June 5, 2026 at 1:43 am

    Neither is good.

    Behaviour should be configured independent of the actual markup. For instance, in jQuery you might do something like

    $('#the-element').click(function () { /* perform action here */ });
    

    in a separate <script> block.

    The advantage of this is that it

    1. Separates markup and behaviour in the same way that CSS separates markup and style
    2. Centralises configuration (this is somewhat a corollary of 1).
    3. Is trivially extensible to include more than one argument using jQuery’s powerful selector syntax

    Furthermore, it degrades gracefully (but so would using the onclick event) since you can provide the link tags with a href in case the user doesn’t have JavaScript enabled.

    Of course, these arguments still count if you’re not using jQuery or another JavaScript library (but why do that?).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a better way to refactor the following method which's purpose is to
For converting a string to an enum, which of the following ways is better?
Let's say that I have 4 models which are related in the following ways:
I use JEditable for making edit field which following code: $(function() { $(.field).editable(http://localhost/index.php/welcome/update_record, {
I found the following which shows how to delete an attribute from XML in
I have the following which works in SQL Query Analyzer . select oh.* from
What is the best way to copy a list? I know the following ways,
I'm looking at the following jQuery call: $.get('/Home/GetResult', null, function (data) { alert(data); });
I have the following tag included in my HTML which causes the JEditorPane not
I use the following which works perfectly in all browsers, except ie9 $result =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.