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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:05:24+00:00 2026-05-31T02:05:24+00:00

I need to pass the contents of an inside div to a function, for

  • 0

I need to pass the contents of an inside div to a function, for example myfun(string). I have tried using

myfun((this).children[0].innerHTML)

myfun((this).children[1].innerHTML)

myfun((this).children[0].children[0].innerHTML)

but none of those seem to work. I can’t just pass the getElementById value because the function should be generic since it would be called by php on various <a> elements (ideally I think it should include the this. keyword).

enter image description here

Thanks for any 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-31T02:05:25+00:00Added an answer on May 31, 2026 at 2:05 am

    in your function, “this” refers to the link, and can’t be used.

    a much cleaner solution would be to have myfunc know that it is going to receive an object which contains the text

    javascript:

    myfunc(obj){
       alert(obj.childNodes[0].nodeValue);
    }
    

    html

       <a href="#" onclick="myfunc(document.getElementByID('target'));return false;">click</a>
       <div id="target">target contents</div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to pass configuration settings to an AddIn created using the Managed AddIn
I'm attempting to pass the contents of a file into a Webview. Using the
I have a need to bulkInsert a lot of data I'm using a content
So I have this Omniture object. It's called s. s Inside s, we keep
I have been following this URL to help me create template views using BrowserView.
I have a requirement where I need to create a dojox.layout.ContentPane programmatically. function constructContentPane(methodToBeCalled){
I need to pass the contents of a textarea as the source attribute of
I am writing an Android app where I need to pass a string array
I have an Object called html inside a Function called tpl() . html =
Possible Duplicate: Is Java pass by reference? I need to modify the content of

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.