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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:53:03+00:00 2026-05-30T12:53:03+00:00

I have a script inside of my HTML file. For example <div id=’mydiv’>Hello World</div>

  • 0

I have a script inside of my HTML file. For example

<div id='mydiv'>Hello World</div>

<script>
$(document).ready(function(){
   var newtext = 'Bye-bye world';
   $('#mydiv').html(newtext);
});
</script>

Now I’d like to move the script to external file and make so, that user can define which html to add to which div. For example

<div id='mydiv'>Hello World</div>
<script>
$(document).ready(function(){
   $('#mydiv').changetext({
      'newtext':'My new text'
   });
});
</script>

How can it be done? Thx

  • 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-30T12:53:05+00:00Added an answer on May 30, 2026 at 12:53 pm

    To use the syntax of your second example you would need to create a plugin.

    (function( $ ){
        $.fn.changetext = function( options ) {  
            var settings = $.extend( {
                'newtext'         : 'Default text'
            }, options);
    
            $(this).text(settings.newtext);
        };
    })( jQuery );
    

    See this link for more information: http://docs.jquery.com/Plugins/Authoring.

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

Sidebar

Related Questions

For example: script.js: function functionFromScriptJS() { alert('inside functionFromScriptJS'); } iframe.html: <html> <head> <script language=Javascript
I include myscript.js in the file http://site1.com/index.html like this: <script src=http://site2.com/myscript.js></script> Inside myscript.js, I
i have a following pattern, inside the html file, that i would like to
I have a huge SVG file inside a DIV. I would like to scroll
I am using jQuery to load a new page inside the div example-placeholder <script>
I have a html file has the general design (some div's) and I need
i have a problem with loading .html pages (with JavaScript inside) into a div
I have a script.js file linking in the head of a HTML page (meta:
I have a script that dynamically loads iframes inside a webpage. You can see
I have created a PHP-script to update a web server that is live inside

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.