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

  • Home
  • SEARCH
  • 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 8837203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:39:55+00:00 2026-06-14T09:39:55+00:00

As a result of my question here: Passing site properties with javascript I’m using

  • 0

As a result of my question here:
Passing site properties with javascript
I’m using the code below to pass text from one div to another in any instance that the data-target is equal to some elements class on a page.

$('#sp').children().each(function() {
    $($(this).data().target).html($(this).html());
});

However, I’m wondering if instead of passing text to an html element, if i could type text on the page that is equal to the data-target value – then have that text be replaced by the text in data target. For example:

<div id="sp" style="display:none;">
<span data-target=".busFullName">My Great Company</span>
</div>

<!-- On some page -->
<p>sp.busFullName has been around since 1920</p>

<!-- Rendered text would be -->
<p>My Great Company has been around since 1920</p>

This way I don’t have to create an extra tag every time i use a property created.

Any insight would be appreciated. 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-14T09:39:56+00:00Added an answer on June 14, 2026 at 9:39 am

    I don’t think you should take this approach since it renders your code semantically meaningless and somewhat unintelligible if JavaScript isn’t available in the client environment. That being said here is how I would have gone about it:

    (function(){
        // Containing element's ID
        var boxID = "#sp";
        // All data-target elements within containing element
        $("[data-target]", boxID).html(function(a,b){
            // Pattern of #id.targetValue
            var pattern = boxID.slice(1) + $(this).data("target");
            // Find everything in body that contains this pattern
            $(":contains("+pattern+")", "body").html(function(c,d){
                // Replace instances of pattern in html with html
                return d.replace(pattern, b);
            });
        });
    })();​
    

    Demo: http://jsfiddle.net/rpHB2/3/

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

Sidebar

Related Questions

I asked a question here about an Linq error that results from mixing Linq-To-SQL
I've a little question about decoding special characters from a JSon result (in my
Here is a simple chunk of code: 1 var selected_clone = selected.clone(); 2 alert(selected_clone.text());
I have a question about preg_replace() function. I'm using it with 'e' modifier. Here
Here is my code. My question has to do with the append function inside
Following on from this question , I'm using a simple ViewModel class to test
My first question here so let's be brief. I am parsing this site: http://78.133.214.226/fotoweb/Grid.fwx
Here is the code: @Repository public interface AccountRepository extends JpaRepository<Account, Long> {} JpaRepository from
I have a question regarding passing a variable that is a char array from
This is a follow-on from a previous question ( here ), but I'm working

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.