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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:58:06+00:00 2026-05-28T07:58:06+00:00

Ok so this i probably very easy but i can’t seem to figure it

  • 0

Ok so this i probably very easy but i can’t seem to figure it out. I have a a function but i still have to call the function inline. I am wondering if there is a way to put it all in the function. Right now my function looks like this:

function ddItem(el) {
 $(el).closest(".ddSelectHeader").find("input").attr({
    value : $(el).text()
})
 }

Then i call this function inline like this:

<div class="ddContainer">
<div class="ddSelectHeader"><input name="" type="text" />
<div class="ddSubmenu">
  <a href="#" onclick="ddItem(this)">Item 1</a><br />
  <a href="#" onclick="ddItem(this)">item 2</a>
  </div>
</div>

Ok so i am trying to make a simple drop down but with divs instead of the traditional ul li. The way it is written above works fine but i was hoping there is a way to take the onlcick out so that any link that is click within the ddSubmenu will populate the input field. This way i don’t have to call it inline or in the html.

Thanks for the help.

  • 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-05-28T07:58:06+00:00Added an answer on May 28, 2026 at 7:58 am
    $(document).ready(function() {
        $(".ddSubmenu a").click(function(){
            var $this = $(this);
    
            $this.closest(".ddSelectHeader").find("input").val($this.text());
        });
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is probably very easy, but I just can't figure out how to solve
this is probably very easy but I can't figure it out :) $('#myDiv').html('<a onclick=remove_item(variantId);>Remove</a>');
this is probably very easy to do, but I can't seem to figure it
This is probably very easy to do but for some reason I can't seem
Probably very easy but I am having trouble to figure this out (also Google
This is probably a very easy question to answer, but I haven't figure out
This will probably be very easy to get a solution for, but I can't
This is probably very easy, but I'm having a hard time figuring it out.
I'm sure this is possible -- and probably very easy -- but I can't
Ok I have a question and it is probably very easy but I can

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.