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 7968211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:02:30+00:00 2026-06-04T07:02:30+00:00

Right now I have this jQuery(‘.widget-prop’).keyup(function() { var prop = jQuery(this).attr(‘id’); var val =

  • 0

Right now I have this

jQuery('.widget-prop').keyup(function() {
    var prop = jQuery(this).attr('id');
    var val = jQuery(this).val();

    stuff;
}

and

jQuery('.widget-prop').click(function() {
    var prop = jQuery(this).attr('id');
    var val = jQuery(this).val();

    stuff;
}

two functions are the same, so I’d like to simplify it by defining external function and calling it with

jQuery('.widget-prop').click('myFunction');

but how would I pass parameters to myFunction?

function myFunction(element) {
    stuff;
}

Thanks

  • 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-04T07:02:31+00:00Added an answer on June 4, 2026 at 7:02 am

    Firstly you can combine both your handlers into one:

    jQuery('.widget-prop').on('click keyup', function() {
        var prop = jQuery(this).attr('id');
        var val = jQuery(this).val();
        // stuff;
    });
    

    Or for older versions of jQuery:

    jQuery('.widget-prop').bind('click keyup', function() { // ... });
    

    Secondly, jQuery will automatically apply the current element to any function you provide, so the this keyword will still be the element raising the event when you do this:

    jQuery('.widget-prop').on('click keyup', myHandler);
    
    function myHandler() {
        var prop = jQuery(this).attr('id');
        var val = jQuery(this).val();
        // stuff;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have right now this code: <ul><li class=listitem>text<li></ul> jQuery: $('.listitem').click(function() { $(#elname).text($(this).text()); $('#slists').css('visibility','hidden') $('#elname').css('visibility','visible')
Right now I have this jquery: $(.updatetwo).click(function () { $('div.result').load('permissions.php); }); I wanted to
I have this code right now: $(document).ready(function () { $(div#main-edit).click( function() { var cursorExists
I have this code right now to get the row value from jquery grid..
right now i have this <script type='text/javascript'> $(#beau).click(function(){ $(#beau).animate({margin-Top: 738px}, fast); }); </script> and
I have this jQuery code: $(.right_box_holder).sortable({ update : function () { var order =
Hi i have this code right now on my website... <script src=http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js type=text/javascript charset=utf-8></script>
I am in a pickle right now... I have this function that gets 2
I have this jQuery code: <script type=text/javascript > $(function() { $('#add_comment').bind('submit',function() //$(input[type=submit]).click(function() { var
I have this JQuery: $(document).ready(function() { $(#generate).click(function() { var texts = []; alert(); $(form

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.